Skip to content

Commit

Permalink
Merge pull request #1690 from CartoDB/bug/ch100627/nikhita-stord-blan…
Browse files Browse the repository at this point in the history
…k-popups-showing-for-a

Fix strange behaviour with previoulsy open popups
  • Loading branch information
antoniocarlon authored Sep 18, 2020
2 parents 8cf53f6 + 7dbbb1e commit 445c7bb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions cartoframes/assets/src/bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -581,12 +581,16 @@ var init = (function () {
}
}

popup
.setLngLat([event.coordinates.lng, event.coordinates.lat])
.setHTML(`<div class="popup-content">${popupHTML}</div>`);
if (popupHTML) {
popup
.setLngLat([event.coordinates.lng, event.coordinates.lat])
.setHTML(`<div class="popup-content">${popupHTML}</div>`);

if (popupHTML.length > 0 && !popup.isOpen()) {
popup.addTo(map);
if (!popup.isOpen()) {
popup.addTo(map);
}
} else {
popup.remove();
}
} else {
popup.remove();
Expand Down
14 changes: 9 additions & 5 deletions cartoframes/assets/src/map/popups.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ export function updatePopup(map, popup, event, attrs) {
}
}

popup
.setLngLat([event.coordinates.lng, event.coordinates.lat])
.setHTML(`<div class="popup-content">${popupHTML}</div>`);
if (popupHTML) {
popup
.setLngLat([event.coordinates.lng, event.coordinates.lat])
.setHTML(`<div class="popup-content">${popupHTML}</div>`);

if (popupHTML.length > 0 && !popup.isOpen()) {
popup.addTo(map);
if (!popup.isOpen()) {
popup.addTo(map);
}
} else {
popup.remove();
}
} else {
popup.remove();
Expand Down

0 comments on commit 445c7bb

Please sign in to comment.