-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Plugin svelte: A11y: on:blur must be used instead of on:change, unless absolutely necessary and it causes no negative consequences for keyboard only or screen reader users. #4946
Comments
My understanding is that's the behavior change you described is actually the entire point of using If the user is accessing the select control with a keyboard, then as they go through the options in the select menu, I'm not an a11y expert, but I think so long as you don't do anything unreasonable in your |
I didn't express myself correctly. I didn't mean to say that the event doesn't trigger as the user goes through the options of the select. I meant that, on a mouse interaction, even after selecting an option, an the option list goes away, still the blur event doesn't get triggered, because the select is still focused I guess. Only after clicking away on some whitespace I see it getting triggered, I can't allow for that sort of ux. |
Ah, I see. Here's the official (as far as I've been able to find) rule that the Svelte one was adapted from: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-onchange.md. Really, I think there's frustratingly little guidance on this rule. It's a big change from what most web developers currently do and the description of the rule is extremely vague on when it's ok to use onchange or not if you aren't already an accessibility expert. The link I posted above has two article links, one of which is dead and the other which is 15 years old: http://www.themaninblue.com/writing/perspective/2004/10/19/ That article is basically is making the case against doing what I mentioned in the last paragraph of my previous comment. This was common back in 2004 when select menus were often used as a kind of simple dropdown navigation, and selecting an option would trigger a page change. But I think that kind of behavior is pretty rare today though. So I would just sum this one up as "make sure your select's on:change handler is friendly to keyboard users" and keep on using on:change. I think that's what I'm going to do. |
There's a webaim.org mailing thread that discusses this issue: https://webaim.org/discussion/mail_thread?thread=8036 Quoting the reply:
|
How do I disable this warning.... on:blur does not work for my use case. It is annoying to see on Visual Studio Code. |
You should be able to use rollup's Not sure about other bundlers but there's probably something similar. |
How would you ignore this warning if you are running Webpack? |
Something I just realized while interacting with this warning — wouldn't this imply that |
Edit your
|
For webpack it's very similar to the solution given by @dennis-f. In the options for // [...]
rules: [
{
test: /\.(svelte|html)$/,
use: {
loader: 'svelte-loader',
options: {
dev,
hydratable: true,
hotReload: false, // pending https://github.com/sveltejs/svelte/issues/2377
onwarn: function (warning, handleWarning) {
if (warning.code === 'a11y-no-onchange') { return }
// process as usual
handleWarning(warning);
}
}
}
},
{
// some other loader here...
}
],
// [...] This option is undocumented in https://github.com/sveltejs/svelte-loader, but it's easy to find it by looking at the source. |
The idea isn't that I think it's probably reasonable for Svelte to push this responsibility onto the developer even when using The a11y warning could be worded better to make it clear that listening to |
I disabled it by putting a comment one line above the warning:
Edit: added select to example |
Thanks, this warning is way over the top. It's absolutely untrue that it doesn't change anything for desktop. |
Imo, this rule should be removed.
The original reasoning behind this rule seemed to be that IE fired the change event when navigating between options with the arrow keys. From the linked article in the jsx-a11y docs:
This was from 2004 and seems to be out of date now. I wrote a quick CodePen to see when the change event is fired for a While older versions of IE may have made this necessary, I don't think it's reasonable to enforce a warning for all developers that only applies to a very small subset of people supporting IE < 11. tl;dr the jsx-a11y this was based on is now deprecated. The rationale is many years old now and not applicable to most use cases when using a modern browser or IE11. |
as there is a growing consensus that this rule should be removed see sveltejs/svelte#4946 (comment)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Since the reaction to my comment above was positive, I've created a PR to remove the warning. |
as there is a growing consensus that this rule should be removed see sveltejs/svelte#4946 (comment)
I recently updated Svelte to latest version and this warning started to show up.
So I decided to try that out, change the
on:change
on some selects toon:blur
, but they stopped working. It's only after I click away from the select that the event gets triggered, simply selecting the option doesn't do it.I know I can simply ignore these, but I wanted to see if I can actually go ahead with this recommendation, maybe I'm doing something wrong. Thanks!
The text was updated successfully, but these errors were encountered: