Focus management between markers and popups
See original GitHub issue(Supersedes https://github.com/Leaflet/Leaflet/issues/2199.)
Is your feature request related to a problem? Please describe.
-
Popups are not reliably announced by screen readers after they’ve been opened
(they may be announced as a side effect of focus shift described in https://github.com/Leaflet/Leaflet/issues/8114, depending on the screen reader).
-
No logical focus order between elements (e.g. marker) and popups
(this would be more reliably solved by https://github.com/Leaflet/Leaflet/issues/8113 for scenarios where the user is simply tabbing between elements and not necessarily opening/closing popups).
(http://bl.ocks.org/skorasaurus/9b2b96967335da91eac7676e815755d2)
-
Focus is not returned to the element that triggered it after a popup has been closed; the user cannot continue where they started before opening the popup.
Describe the solution you’d like
Screen readers announce content on focus delegation, and even though the modern best practice is to focus an element inside popups/dialogs Leaflet can’t guarantee interactive content inside popups, so the suggestion is to focus the popup itself:
- Set
tabindex="-1"
onleaflet-popup-content-wrapper
(to enable programmatic focus) - Send focus to
leaflet-popup-content-wrapper
after the popup has been opened by the user - Send focus back to the source element (e.g. marker) after the popup has been closed (via <kbd>Esc</kbd> or the Close button)
- https://github.com/Leaflet/Leaflet/issues/7968 (on
leaflet-popup
), can be decided later
Additional context
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:9 (4 by maintainers)
Top GitHub Comments
Thanks for creating a new issue; I updated the test case that y’all can use; uses leaflet 1.8.0; it’s now at http://skorasaurus.github.io/maptemplates/leaflet-test-8115.html to reflect the new issue number.
After closing a popup with the close button, the focus should go back to the marker of the popup