question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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.

  1. 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).

  2. 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).

    #2199 (comment):

    leaflet-tab-issue 2018-12-03 at 16 35 17

    (http://bl.ocks.org/skorasaurus/9b2b96967335da91eac7676e815755d2)

  3. 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:

  1. Set tabindex="-1" on leaflet-popup-content-wrapper (to enable programmatic focus)
  2. Send focus to leaflet-popup-content-wrapper after the popup has been opened by the user
  3. Send focus back to the source element (e.g. marker) after the popup has been closed (via <kbd>Esc</kbd> or the Close button)
  4. https://github.com/Leaflet/Leaflet/issues/7968 (on leaflet-popup), can be decided later

Additional context

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
skorasauruscommented, Apr 21, 2022

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.

2reactions
Falke-Designcommented, Apr 20, 2022

After closing a popup with the close button, the focus should go back to the marker of the popup

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make other markers go below custom divIcon popup, instead ...
PROBLEM: When the popup is showing, any other markers on the map show on top of the popup, instead of underneath. I have...
Read more >
Pop-ups: They're making a resurgence! - Chrome Developers
For focus management, you can use the autofocus attribute to move focus to an element inside a popover. This is the same as...
Read more >
Marker Accessibility | Maps JavaScript API - Google Developers
This example creates five markers which are accessible. The first marker receives focus when tab is pressed; you can then use the arrow...
Read more >
Markers and Popups | VMapbox
focusAfterOpen {Boolean} If true, the popup will try to focus the first focusable element inside the popup. coordinates {Array} The GeoJSON ...
Read more >
Popup | Workday Canvas Design System
Focus management is important to accessibility of popup contents. The following example shows useFocusRedirect being used to manage focus in and out of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found