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

Rule proposal: require clickable non-button/non-link elements listen for space or enter #77

Closed
lencioni opened this issue Aug 23, 2016 · 7 comments
Assignees

Comments

@lencioni
Copy link
Contributor

If you are making a non-button or non-link element clickable, you also need to wire up keyboard listeners for space and enter. While I don't think we will be able to ensure that this is all implemented correctly, we can likely at least add a warning for any DOM element that is not a or button that has onClick and not a keyboard event listener.

cc @backwardok

@backwardok
Copy link
Collaborator

Btw I think also inputs work as well - essentially form elements and links should have that behavior default. It's the elements that you're adding non default behavior to where you have to also add in keyboard listeners

@lencioni
Copy link
Contributor Author

Oh right, of course.

@ljharb
Copy link
Member

ljharb commented Aug 23, 2016

For purposes of semantic markup, why would we want to encourage adding onClick to a non-natively-clickable thing anyways?

@lencioni
Copy link
Contributor Author

Yeah, it should likely suggest using a button or link first, or alternatively adding the keyboard stuff.

@ljharb
Copy link
Member

ljharb commented Aug 23, 2016

Do we have another rule that can actively prohibit adding interaction behavior to non-natively-interactable DOM elements?

@beefancohen
Copy link
Contributor

Do we have another rule that can actively prohibit adding interaction behavior to non-natively-interactable DOM elements?

No but we have onclick-has-role, which requires adding the role prop to non-natively-interactable DOM elements with click handlers.


just to clarify, this seems like we are taking the logic for determining non-interactive DOM elements from onclick-has-role and enforcing that those elements with onClick handlers have accompanying onKeyDown, onKeyUp, or onKeyPress props.

rule: click-events-have-key-events (similar to mouse-events-have-key-events)

@ljharb
Copy link
Member

ljharb commented Aug 24, 2016

@beefancohen beefancohen self-assigned this Aug 24, 2016
beefancohen added a commit that referenced this issue Aug 25, 2016
…s rules (#79)

* [new] - Implement click-events-have-key-events rule

Fixes #77

* [new] - Implement no-static-element-interactions rule.

Fixes #78

* [docs] - Cleanup & write docs for new rules.

* [docs] - clean up new rule documentation.
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

4 participants