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

Popup close button adding #close hash to URL #8159

Closed
gwacker opened this issue Apr 19, 2022 · 8 comments · Fixed by #8160
Closed

Popup close button adding #close hash to URL #8159

gwacker opened this issue Apr 19, 2022 · 8 comments · Fixed by #8160
Labels
accessibility Anything related to ensuring no barriers exist that prevent interactions or information access bug
Milestone

Comments

@gwacker
Copy link

gwacker commented Apr 19, 2022

Starting with version v1.8.0, clicking the popup close 'x' button adds #close to the URL

Behavior is reproducible on the leaflet.js website in examples with popups such as:
https://leafletjs.com/SlavaUkraini/examples/quick-start/example.html

Previous to v1.8.0 clicking the popup close button prevented #close hash from being added to the URL

Not ideal for Single Page Applications that rely on hash routing.

@IvanSanchez
Copy link
Member

Can confirm (firefox, linux). Doesn't happen on 1.7.0 (see https://plnkr.co/edit/TFdFTrIxdQXXOccK , make sure to open up the preview in a separate tab).

Doing a git blame of the relevant file points at #7794 and #6639 like the possible culprits of this regression. Not sure if this is something triggered by the ARIA attributes, or if something slipped by in the tooltip refactor, but doing a preventDefault of the click event seems to work.

@IvanSanchez IvanSanchez added bug accessibility Anything related to ensuring no barriers exist that prevent interactions or information access labels Apr 19, 2022
@Falke-Design
Copy link
Member

While refactoring, DomEvent.stop(e) was removed:

grafik

@IvanSanchez
Copy link
Member

Ah, so the source of the regression is #7439 , I see.

@jonkoops jonkoops added this to the 1.8.1 milestone Apr 19, 2022
@jonkoops
Copy link
Collaborator

Added this to the 1.8.1 milestone, looks like a regression we should fix in the next patch release.

@youssefbandak
Copy link

youssefbandak commented May 13, 2022

yes i faced this issue yesterday:
Cause : The X button to close the pop up is placed as "<a class="leaflet-popup-close-button" href="#close">×"
so it is redirecting the app

Solutions:
1- remove the Close buttton
const popup = L.popup({
closeButton: false
})
2- catch the event onclose and change href (but it will refresh the page) not recommended
marker.getPopup()?.on('remove', (e) => {
e.target._closeButton.href = this.router.url;
});

3- Change Leaflet version from 1.7.1 to striclty 1.7.0 (saved me)

@Falke-Design
Copy link
Member

Change Leaflet version from 1.7.1 to striclty 1.7.0 (saved me)

The problem occurs since Leaflet 1.8.0 so it makes no difference if you use 1.7.1 or 1.7.0

@Mackulus
Copy link

Change Leaflet version from 1.7.1 to striclty 1.7.0 (saved me)

The problem occurs since Leaflet 1.8.0 so it makes no difference if you use 1.7.1 or 1.7.0

I work on an app exhibiting the same behavior on leaflet 1.7.1 and changing to 1.7.0 stopped the behavior. So it does make a difference

@digital-codes
Copy link

Can confirm the error with 1.8.0, is solved when going back to 1.7.0
Closing the popup shouldn't route anywhere, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accessibility Anything related to ensuring no barriers exist that prevent interactions or information access bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants