From c6646fc5ae5ec184aefa1657f0d28f8ba42edc3e Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Wed, 14 Aug 2019 15:15:50 +0200
Subject: [PATCH] clear button hides reaction info window

---
 CHANGELOG                                                  | 1 +
 .../src/main/js/map/canvas/OpenLayers/OpenLayerPolyline.js | 5 ++++-
 .../src/main/js/map/marker/MarkerSurfaceCollection.js      | 7 ++++++-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG b/CHANGELOG
index a10cdb0079..2038d57a54 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@ minerva (13.1.3) stable; urgency=medium
     page (#870)
   * Bug fix: submap list must be selected to export from every submap (#874)
   * Bug fix: export map as image properly uses bottom limit (#875)
+  * Bug fix: reaction info window wasn't closed on CLEAR (#876)
 
  -- Piotr Gawron <piotr.gawron@uni.lu> Wed,  14 Aug 2019 17:00:00 +0200
 
diff --git a/frontend-js/src/main/js/map/canvas/OpenLayers/OpenLayerPolyline.js b/frontend-js/src/main/js/map/canvas/OpenLayers/OpenLayerPolyline.js
index 6ee77ee559..e4eab7e4c4 100644
--- a/frontend-js/src/main/js/map/canvas/OpenLayers/OpenLayerPolyline.js
+++ b/frontend-js/src/main/js/map/canvas/OpenLayers/OpenLayerPolyline.js
@@ -12,6 +12,8 @@ function OpenLayerPolyline(options) {
 
   var self = this;
 
+  self.registerListenerType("onHide");
+
   if (options.strokeColor === undefined) {
     options.strokeColor = "#000000";
   }
@@ -74,7 +76,8 @@ OpenLayerPolyline.prototype.show = function () {
 };
 
 OpenLayerPolyline.prototype.hide = function () {
-  return this.getOpenLayersPolyline().setStyle(new ol.style.Style({}));
+  this.getOpenLayersPolyline().setStyle(new ol.style.Style({}));
+  return this.callListeners("onHide");
 };
 
 OpenLayerPolyline.prototype.isShown = function () {
diff --git a/frontend-js/src/main/js/map/marker/MarkerSurfaceCollection.js b/frontend-js/src/main/js/map/marker/MarkerSurfaceCollection.js
index c9634456b4..8ab253ea91 100644
--- a/frontend-js/src/main/js/map/marker/MarkerSurfaceCollection.js
+++ b/frontend-js/src/main/js/map/marker/MarkerSurfaceCollection.js
@@ -228,7 +228,12 @@ MarkerSurfaceCollection.prototype.createSurfaceForDbOverlay = function (element,
         onClick: onclickFunctions
       });
       result.addListener("onClick", function () {
-        return map.getTopMap().openInfoWindowForIdentifiedElement(element);
+        return map.getTopMap().openInfoWindowForIdentifiedElement(element).then(function (infoWindow) {
+          result.getMapCanvasObjects()[0].addListener("onHide", function () {
+            return infoWindow._infoWindow.hide();
+          });
+          return infoWindow;
+        });
       });
       self.putSurface({element: element, overlay: dbOverlay}, result);
       if (self.getMap().isInitialized()) {
-- 
GitLab