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

Lighthouse is reporting: Form elements do not have associated labels #468

Open
Zodiac1978 opened this issue Sep 17, 2022 · 0 comments
Open

Comments

@Zodiac1978
Copy link
Member

Reported here: https://wordpress.org/support/topic/accessibility-form-elements-do-not-have-associated-labels-2/#post-16019004

Lighthouse seems to analyze the pages without running JS, so it misses the connection between the <label for="comment"> markup and the real comment form. Because we add the id="comment" with JS afterwards.

https://github.com/pluginkollektiv/antispam-bee/blob/master/antispam_bee.php#L1259-L1292

A possible solution from the forums:

usually the connection is between ref on the label and id of the text-area. With aria-properties you can reverse it. So I added aria-labelledby=”comment-lbl” to the first textarea in antispam_bee.php and made a comment-form textarea override in my theme and put an id=”comment-lbl” to the standard label of the text-area. So the label references the hidden textarea with the standard way ref and id and the real textarea is referenced reverse with labelledby and id. This brings 100% score for me in the Lighthouse-Test and I think it probably will not break the spam-protection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant