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.

When Tabbing through map, focus outline flashes but does not stay lit up

See original GitHub issue

Try to use Tab to advance through focusable elements in a Leaflet map. For example, try with the example map on the Leaflet homepage (https://leafletjs.com/). Elements including the “x” to close the popup, the zoom in (“+”) and zoom out (“-”) controls, and the bottom-right corner links for “Leaflet” and “OpenStreetMap”, will briefly flash the focus ring, but it will then disappear. The element is actually still focused, there is no visible indication. Among other things, this is a nightmare for accessibility.

This seems to be occurring because the Map _handleDOMEvent function calls DomUtil.preventOutline for all mousedown, keypress, keyup, and keydown events. DomUtil.preventOutline is injecting outline: none into the element.style. With the caveat that I am not familiar with this code base, I don’t understand this approach. If the desire is to remove the focus ring outline, why wouldn’t this be done with CSS on :focus? This would prevent the brief focus ring flash, and it would allow for it to be overridden in CSS (without resorting to !important).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:10
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Malvozcommented, Mar 21, 2020

This is a failure of WCAG 2.1 - Success Criterion 2.4.7 Focus Visible.

If outlines are undesirable for some reason, :focus-visible allows for only displaying them on keyboard navigation, which is when it becomes an accessibility issue if they’re not displayed to the user.

1reaction
Malvozcommented, Sep 5, 2020

If you (@akrawitz, @matthoylu, and others) wish to restore the focus outline in your own stylesheet as a quickfix, here’s a snippet that should cover most browsers:

.leaflet-container :focus {
  outline: -webkit-focus-ring-color auto thin !important; /* Fallback for some browsers that don't support `revert`. */
  /* Longhand properties:
  outline-color: -webkit-focus-ring-color !important;
  outline-style: auto !important;
  outline-width: thin !important;
  */
  outline: revert !important;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Weird outline behavior when tabbing through links in ...
Here is my code which causes the behavior. To Reproduce: Focus HTML Body by clicking on the grey div; Navigate through the links...
Read more >
Ext.tab.Panel | Ext JS 6.2.0
It is easy to control the visibility of items in the tab bar. Specify hidden: true to have the tab button hidden initially....
Read more >
How to fix the ugly focus ring and not break accessibility in ...
Go ahead and implement the outline: none; hack, and then try to tab through your page to get to your element to select...
Read more >
Having a Little Fun With Custom Focus Styles
Select the focused state of the element and apply a contrasting background color to it. The higher the contrast the better because subtle ......
Read more >
Pop-ups—ArcGIS Pro | Documentation
When displaying feature layers in a map or scene, you can list attributes and ... crosshairs when flashing on the Navigation tab 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