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.

Use `tabindex="0"` instead of `href="#"` for controls?

See original GitHub issue

Ideally <button> should be used for controls (https://github.com/Leaflet/Leaflet/issues/7821), however migrating from <a> to <button> is likely to break a lot of selectors in the wild. Instead, it may be better to use tabindex="0" for now (same as for markers), as it behaves more similarly to <button>:

  1. tabindex="0" does not prompt a URL to be displayed when hovered/focused (more aesthetically pleasing, but also removes a potential source of confusion for some users):


  2. tabindex="0" does not cause a “touch callout” on taphold:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jonkoopscommented, Nov 30, 2021

Perfect, we can see if we can land that in another PR. I personally have no objections for adding a tabindex="0" here.

1reaction
Malvozcommented, Nov 28, 2021

I personally think we should use the button element here, a link is semantically wrong as we aren’t actually linking anywhere. This would be a breaking change we can make in Leaflet 2.

@jonkoops note that most controls use the correct semantics due to role="button" (there are some controls that don’t, I’ve opened issues for those). Anyhow, I’ve opened https://github.com/Leaflet/Leaflet/issues/7821 for moving from <a> to <button>.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is tabIndex: 0 in links considered a good practice in order to ...
Tabindex=0 will make your links focusable but not clickable. Instead of just using # , use the id attribute of the item which...
Read more >
Control focus with tabindex - web.dev
Insert an element into the tab order #. Insert an element into the natural tab order using tabindex="0" . For example:.
Read more >
tabindex - HTML: HyperText Markup Language | MDN
The tabindex global attribute indicates that its element can be focused, and where it participates in sequential keyboard navigation ...
Read more >
How and when to use the tabindex attribute - bitsofcode
tabindex is a global attribute that can be applied to most HTML elements with content. It controls two things: If an element is...
Read more >
How-to: Use the tabindex attribute - The A11Y Project
tabindex is a global attribute that allows an HTML element to receive focus ... Instead, use appropriate interactive elements ( a for links, ......
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