Skip to content

Improve click event handler accessibility warning #8001

Closed
@brunnerh

Description

@brunnerh

Describe the problem

There is a this warning when adding a click event handler to non-interactive elements:

A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event.

For users that do not know what this is really about, the only clear instruction here is: Add more event handlers.

Which is backwards and will not even work half of the time because the element would also have to be focusable and semantics will still be missing for screen readers.

Describe the proposed solution

Start the warning with a suggestion to use the appropriate elements:
Use a button element for actions, use an a element for navigation.

A note on button behavior in forms may be helpful. I.e. the default type of buttons is submit and that one might want to add type="button" to change this.

(The documentation for the warning should also include this as the primary suggestion.)

Alternatives considered

N/A

Importance

nice to have

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions