-
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
Don't allow href="#"
links
#12535
Comments
I'm personally not convinced we should do this because there's so many ways people can hack HTML elements in the wrong way. The |
One point that's been argued about Gutenberg as a framework is that by enforcing certain standards of accessibility in implementation, it hardens the overall accessibility of the system, making it harder for plugins to insert inaccessible controls. I think it's important that we do what we can to prevent accessibility problems. Everything is hackable in some way, so it's understood that we can't protect against every possibility; but having some protection against common errors seems important. |
Sounds like we could need a |
@joedolson @swissspidy |
Probably just console, otherwise it might break something or confuse users. |
Actually, this proposal makes a lot of sense. Using only console for warnings is very limiting, plugins should be also able to intercept such messages and decide what to do about them. I think it was discussed during weekly core JS chats. @adamsilverstein or @aduth, do you recall whether we agreed on something actionable? This issue might be good excuse to investigate that. |
I don't recall such a conversation. The closest thing which comes to mind was a prior discussion about how |
The above conversation (specifically that about filterability of https://wordpress.slack.com/archives/C5UNMSU4R/p1536066127000100 |
See also my related comment in #11631 (comment):
I think this would be the best way to address this issue and it would allow creating a utility method fo a wider usage. I also agree that it should be similar to what |
Splitting this out from #12309 (comment)
#12309 introduces the ability for developers to add links in the More menu. Also link with an incomplete URL fragment identifier, i.e.
href="#"
can be added. Unfortunately, this is a largely adopted bad practice: UI controls that behave like buttons should be<button>
elements. Links should trigger navigation. For WordPress core, see https://core.trac.wordpress.org/ticket/26504 which is an a11y "blessed task".Also links that have a fragment identifier e.g.
href="#some-id-in-the-page"
but then the referenced ID doesn't exist, should not be allowed.It would be great to explore a way to check the passed url value. The first case should be simple to address: if the URL value is just
#
then an error should be thrown.Not sure how to address programmatically the second case. Maybe automated accessibility tests could help in this case.
The text was updated successfully, but these errors were encountered: