-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
A11y: A form label must be associated with a control. (When label actually has control element) #5528
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
There is opened PR but there are no opened issues about this bug. That's the reason why I opened this issue |
Possible related: https://svelte.dev/repl/c16ecfdb7f484b5190692bb08bd0ea32?version=3.29.0 Warning if the actual form element is conditional <label>
{#if A}
<input type="text">
{:else}
<textarea></textarea>
{/if}
</label> This gives: "A11y: A form label must be associated with a control." |
I guess this warning should be emitted? Checking recursively all child elements, components, conditions, etc. may be really slow and the implementation is not so easy |
I'm suffering this warning as well. If it happens on own components, we just set "id" and "for". But if it happens on library's components, we can't fix it. At least, I'd like to avoid this situation. |
Pay attention that if you will use one component with static id inside more than once in the same document it won't be valid html markup. That's the reason why this workaround is not for everyone. |
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. |
I think this warning should appear only if label 100% can't have control element. I'll try to give example or even PR soon |
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. |
Fixed in 3.50.0 - https://svelte.dev/repl/418bcf45f55741e49361839687cf11fa?version=3.50.0 |
Case when labelable element is not direct child of label element triggers current warning
https://svelte.dev/repl/418bcf45f55741e49361839687cf11fa?version=3.29.0
Expected behavior: compiler recursively checks if label has labelable element
Additional context:
I started to write recursive function to get this warning working properly but then I found #5323 PR that covers my issue
The text was updated successfully, but these errors were encountered: