diff --git a/cartoframes/assets/src/bundle.js b/cartoframes/assets/src/bundle.js
index c81dc6a83..67658c021 100644
--- a/cartoframes/assets/src/bundle.js
+++ b/cartoframes/assets/src/bundle.js
@@ -581,12 +581,16 @@ var init = (function () {
}
}
- popup
- .setLngLat([event.coordinates.lng, event.coordinates.lat])
- .setHTML(`
`);
+ if (popupHTML) {
+ popup
+ .setLngLat([event.coordinates.lng, event.coordinates.lat])
+ .setHTML(``);
- if (popupHTML.length > 0 && !popup.isOpen()) {
- popup.addTo(map);
+ if (!popup.isOpen()) {
+ popup.addTo(map);
+ }
+ } else {
+ popup.remove();
}
} else {
popup.remove();
diff --git a/cartoframes/assets/src/map/popups.js b/cartoframes/assets/src/map/popups.js
index df3ff6e7f..1cbf31159 100644
--- a/cartoframes/assets/src/map/popups.js
+++ b/cartoframes/assets/src/map/popups.js
@@ -47,12 +47,16 @@ export function updatePopup(map, popup, event, attrs) {
}
}
- popup
- .setLngLat([event.coordinates.lng, event.coordinates.lat])
- .setHTML(``);
+ if (popupHTML) {
+ popup
+ .setLngLat([event.coordinates.lng, event.coordinates.lat])
+ .setHTML(``);
- if (popupHTML.length > 0 && !popup.isOpen()) {
- popup.addTo(map);
+ if (!popup.isOpen()) {
+ popup.addTo(map);
+ }
+ } else {
+ popup.remove();
}
} else {
popup.remove();