Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix strange behaviour with previoulsy open popups #1690

Merged

Conversation

antoniocarlon
Copy link
Contributor

Fix strange behaviour with previoulsy open popups

@@ -51,9 +51,12 @@ export function updatePopup(map, popup, event, attrs) {
.setLngLat([event.coordinates.lng, event.coordinates.lat])
.setHTML(`<div class="popup-content">${popupHTML}</div>`);

if (popupHTML.length > 0 && !popup.isOpen()) {
if (!popup.isOpen()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would avoid setting and adding, and removing the popup every time. We could try something like this instead:

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

    if (!popup.isOpen()) {
      popup.addTo(map);
    }
} else {
    popup.remove();
}

@antoniocarlon
Copy link
Contributor Author

@Jesus89 new CR round?

@antoniocarlon antoniocarlon merged commit 445c7bb into develop Sep 18, 2020
@antoniocarlon antoniocarlon deleted the bug/ch100627/nikhita-stord-blank-popups-showing-for-a branch September 18, 2020 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants