-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Closing Popup by pressing Escape doesn't work in all cases #6551
Comments
I'm wondering why the I've made a branch where the KeyBoard-Handler adds the listeners to container and not the whole |
Because keyboard events only fire/bubble on
Because a Leaflet map container is often a non-focusable-by-default The current code attaches |
@IvanSanchez's #6551 (comment):
#8115 as proposed requires the popup's container to be programmatically focusable via |
hello, I've modified the Popup class's Layer to include a keydown eventListener to close the popups. ( PR #8239 ) Edited Plunkrs for demonstration |
Description
The keyboard handler adds the
keydown
-Listener to the whole document and not to the map-container element.In order not to interfere with other keyboard-events, the
keydown
-listener gets registered when the map-container receives focus and gets removed when a blur event on the map-container occurs.Leaflet/src/map/handler/Map.Keyboard.js
Lines 56 to 59 in 37d2fd1
Leaflet/src/map/handler/Map.Keyboard.js
Lines 71 to 74 in 37d2fd1
Leaflet/src/map/handler/Map.Keyboard.js
Lines 132 to 138 in 37d2fd1
When the marker gets clicked, it receives focus, therefore the map container looses focus and triggers a blur event. The blur event disables the Keyboard-Handler and the opened popup can't be closed by pressing Esc because the Keyboard-Handler is disabled.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
The opened popup should be closed then the Esc-Key is pressed
Current behavior
The popup get's only closed when the layer the popup is bound to is not focusable
Environment
Minimal example reproducing the issue
https://next.plnkr.co/edit/Soh1otCSsfdBBCi0
The text was updated successfully, but these errors were encountered: