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.

Layer control should have `role="button"`

See original GitHub issue

Motivation

The layer control is intended as (and behaves similarly to) a button, not a link, and should be conveyed as such to screen reader users.

Proposed solution

Set attribute role="button" on the <a> element:

https://github.com/Leaflet/Leaflet/blob/b52961aa469dc17b3710ef7a9c0f13b6f4dba550/src/control/Control.Layers.js#L201-L203

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Malvozcommented, Mar 26, 2021

@wiesesascha that’s probably a separate issue. ARIA semantics only affects users of assistive technology (ATs), in this case role="button" would convey to these users that this element is a button (that it is actionable, and with which behavior, i.e. button behavior as opposed to link behavior), and because ATs can intercept keyboard input, in some cases it is even required for an otherwise clickable element to be operable (for example markers aren’t keyboard operable when using a screen reader, presumably since they’re not standard interactive elements).

0reactions
Malvozcommented, May 21, 2021

@vanillajonathan Indeed, that’d be optimal (noted in https://github.com/Leaflet/Leaflet/issues/3210#issue-4). It requires a CSS button reset (not very hard to accomplish) but OTOH it’s not backwards compatible with people’s code, so that’s a consideration.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ARIA: button role - Accessibility - MDN Web Docs
The button role is for clickable elements that trigger a response when activated by the user. Adding role="button" tells the screen reader ...
Read more >
Do I need role="button" on a <button>? - Stack Overflow
Using role=button on a button element. You do not need to use role=button in general, as button elements have strong native semantics.
Read more >
Do I need aria attributes or roles on native elements?
Most of the time, no you don't. If you are using a <button> element as a button or an <a> element as a...
Read more >
Enough with the role-play—let's get back to the basics - TPGi
If your HTML has `role` attributes throughout, chances are there are better native elements you should use instead.
Read more >
Custom Controls | Web Accessibility Initiative (WAI) - W3C
To ensure robustness, try to reuse HTML elements that do a subset of the ... The example below shows a social media “share...
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