Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessible buttons #713

Closed
Malvoz opened this issue Dec 1, 2020 · 6 comments · Fixed by #721
Closed

Accessible buttons #713

Malvoz opened this issue Dec 1, 2020 · 6 comments · Fixed by #721
Labels
fixed Issues that are fixed in develop or in a PR improvement

Comments

@Malvoz
Copy link

Malvoz commented Dec 1, 2020

<a> buttons (such as <a class="leaflet-buttons-control-button"> and <a class="leaflet-pm-action">) are not keyboard focusable/operable. Additionally, they're announced as "link" using a screen reader (missing role="button"). Otherwise <button type="button"> is recommended, but requires additional styling to reset browser defaults.

See related resources:

@Falke-Design
Copy link
Collaborator

@Malvoz can you please look if the PR #721 is working for you. It was not possible to add href = '#' because then the page was scrolling to the top

@Malvoz
Copy link
Author

Malvoz commented Dec 8, 2020

@Falke-Design In that case tabindex="0" could be used (see https://web.dev/control-focus-with-tabindex/).

@Falke-Design
Copy link
Collaborator

Ok I added the tabindex.
Did you ment to use the tabindex togheter with the href? Because then it is the same problem as before, the page is scrolling.

@Malvoz
Copy link
Author

Malvoz commented Dec 8, 2020

Yes tabindex=0 alone is sufficient to get the controls into tab order, along with appropriate keyboard event listener, would make them accessible and operable for keyboard-only users.

@Falke-Design
Copy link
Collaborator

@Malvoz is it possible to make a click on keyboard enter like a click in leaflet without adding a key-event listener? A browser default function like tabindex?

Because now it is possible to tab through the draw buttons but it is not possible to activate them with enter

@Falke-Design
Copy link
Collaborator

Falke-Design commented Dec 30, 2020

To make buttons accessible with enter, the button needs href="#", but then the page is scrolling to the clicked element. To prevent this e.preventDefault(); have to be added to the click event:

    newButton.setAttribute('role','button');
    newButton.setAttribute('tabindex','0');
    newButton.href = '#';
    L.DomEvent.on(newButton, 'click', (e)=>{
        e.preventDefault(); 
        console.log(e);
    }); // click event

@Falke-Design Falke-Design added the fixed Issues that are fixed in develop or in a PR label Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed Issues that are fixed in develop or in a PR improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants