-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
A11y on:click event must be accompanied by an on:keydown — add assignment like on:click=on:keydown={} #7958
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
Comments
Oh no 😨 You forgot the most important bit of the message which is non-interactive elements. In general the solution is to use interactive elements such as In other cases where you know you don't need it you can still apply |
The things you should be putting If you do want a keyboard handler on the element, you're likely going to want different handlers for clicking and keydown (because otherwise your code would be triggered for every key, including tab, arrow keys, etc.). If you find yourself in this situation frequently, I would encourage you to write a simple action that encapsulates this logic and attaches the appropriate mouse and keyboard actions. I don't think this is something the framework ought to handle. And lastly, no, we definitely don't want to be attaching implicit keydown handlers when you attach a click handler. |
@Conduitry @Rich-Harris With all the focus on accessibility, it would be great to have at least one article on best practices from Svelte standpoint. All the warnings are a great stick, but there's no carrot, no easy path to follow. It's frustrating, since dynamic links can be done in dozen ways and Svelte seem to be trying to push you to use one specific, but doesn't tell you exactly which one. span on:click in a problem, span with tabindex is problem, <a href='javascript:' is a problem, <a href='#' is a problem, <a without href is a problem... etc etc. So a developer who would like to do the right thing but doesn't have much time to invest into it just throws hands into the air and disables A11y altogether. For example this:
It's a navigation thing, so semantically it should use "A" tag. But href doesn't make sense. Buttons are also styled in a different way, so using a button would require additional css reset just for that specific button. |
Agreed. When I search the Svelte documentation for That tells me I should use There's nothing in the event handling section of the tutorial, either — it's all about clicks. If the Svelte documentation doesn't tell us how to write a keyup handler, Svelte should not be complaining that we haven't done so! |
Describe the problem
To work with a11y, in addition to clicking, you need to register the processing of keyboard pressing. In this case, if the call function is the same, there is duplication and littering of the code.
I would like to be able to list several types of call in a row.
Describe the proposed solution
These could be solutions:
on:click=on:keydown={}
or
on:click|:keydown={}
or custom method
on:ckd={}
Alternatives considered
Alternatively, make the click method automatically duplicate keydown if no special definition is specified
Importance
would make my life easier
The text was updated successfully, but these errors were encountered: