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

no-static-element-interactions message suggests adding a role, but not changing the element. #761

Closed
threehams opened this issue Dec 1, 2020 · 3 comments · Fixed by #843

Comments

@threehams
Copy link

(sorry about the title, this is a very tough title to write)

The docs for the no-static-element-interactions rule cover two common cases of needing a static element.

The message on error:

Static HTML elements with event handlers require a role.

This typically happens in pairs with click-events-have-key-events:

Static HTML elements with event handlers require a role. (jsx-a11y/no-static-element-interactions)
Visible, non-interactive elements with click handlers must have at least one keyboard listener. (jsx-a11y/click-events-have-key-events)

However, both the docs and message are dancing around an issue: people use clickable divs because they don't know any better. Making an interactive div accessible requires a minimum of 3 extra properties, plus all the keyboard event handlers on top of click handlers (and all the keyCode listening necessary to match the role). The best fix for this rule is almost always to change the static element into an interactive element, but the message sends people down a more difficult and verbose path.

Would you be willing to accept a change to have the message reflect this? I'm struggling with grammar consistency, but something like:

A static HTML element with an event handler requires a role, or should be replaced with an interactive element.
@ljharb
Copy link
Member

ljharb commented Dec 1, 2020

That makes sense to me. @jessebeach?

@jessebeach
Copy link
Collaborator

I agree with @threehams that the best solution is a semantic element. So I suggest leading with that, rather than pushing the optimal recommendation to the end of the sentence after an or clause. Something like:

The best replacement for an interactive static element is the corresponding semantic HTML element. In the case that this replacement is not possible, then an interactive static element requires a role and tabbing support as well as interaction support for mouse, keyboard and touch inputs.

@SalahAdDin
Copy link

It is even not clear for me which are the static elements.

uncommon-type added a commit to uncommon-type/eslint-plugin-jsx-a11y that referenced this issue Mar 16, 2022
- Recommend using native HTML whenever possible
- If using native counterpart is impossible, recommend adding to all
interactive non-semantic elements an appropriate role along with
support for mouse, keyboard and touch inputs.

Fixes jsx-eslint#761
uncommon-type added a commit to uncommon-type/eslint-plugin-jsx-a11y that referenced this issue Mar 16, 2022
- Recommend using native HTML whenever possible
- If using native counterpart is impossible, recommend adding to all
interactive non-semantic elements an appropriate role along with
support for mouse, keyboard and touch inputs.

Fixes jsx-eslint#761
uncommon-type added a commit to uncommon-type/eslint-plugin-jsx-a11y that referenced this issue Mar 16, 2022
- Recommend using native HTML whenever possible
- If using native counterpart is impossible, recommend adding to all
interactive non-semantic elements an appropriate role along with
support for mouse, keyboard and touch inputs.

Fixes jsx-eslint#761
ljharb pushed a commit to uncommon-type/eslint-plugin-jsx-a11y that referenced this issue Mar 16, 2022
- Recommend using native HTML whenever possible
- If using native counterpart is impossible, recommend adding to all
interactive non-semantic elements an appropriate role along with
support for mouse, keyboard and touch inputs.

Fixes jsx-eslint#761
@ljharb ljharb closed this as completed in 0f1615a Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants