Skip to content

Don't allow href="#" links #12535

Open
Open

Description

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.

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

Metadata

Assignees

No one assigned

    Labels

    Needs DevReady for, and needs developer efforts[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions