illright / attractions

A pretty cool UI kit for Svelte
https://illright.github.io/attractions
MIT License
1.03k stars 37 forks source link

Prevent svelte compiler from throwing accessibility warnings where we only care about the click event #369

Closed noosxe closed 1 year ago

noosxe commented 1 year ago

Svelte compiler complains about non-interactive elements with on:click handlers not having a keyboard alternative for a11y purposes.

This change adds missing event handlers.

aabounegm commented 1 year ago

Thank you for this contribution, but are you sure that treating all keypresses equally is the right thing to do here? I think people generally expect mouse clicks to be equivalent to pressing only Enter and/or Space

noosxe commented 1 year ago

@aabounegm thanks for your comment.

I dug a little bit deeper and decided to just prevent the compiler from throwing the errors for these cases.

There is no point in adding keyboard event handlers at all because the elements can't be navigated to using a keyboard anyway. The "real" accessibility is handled by elements that are wrapped by the ones that were throwing warnings in case of the autocomplete-option and file-dropzone. In case of modal clicking on the backdrop to hide the modal is useful but doing the same with the keyboard is not because keyboard users can instantly jump to the close button itself.

github-actions[bot] commented 1 year ago

Docs available on https://illright.github.io/attractions/369/