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

Check elements with mouse event handlers #70

Merged

Conversation

tricinel
Copy link
Contributor

HTMLElements (excluding <a> and <button) that use mouse event handlers without accompanying keyboard handlers and proper HTML attributes can be unreachable via the keyboard.

This fails Success Criterion 1.3.1 and 2.1.1.

A demo of the change is in this Codepen.

Thank you so much to @alvaromontoro for the assist in figuring out the proper combination of selectors to check for to ensure a div could be made accessible.

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

When HTMLElements use mouse event handlers such as onclick, ondblclick, onmouseup/down, onmouseenter/leave or onmouseover, without providing the proper alternatives (i.e. onkeydown/up/press, no or wrong tabindex and no or wrong role), they could become unreachable via the keyboard.

We therefore should warn users of the danger, but it is ultimately up to them if they want to ignore it because they might have, for example, provided some alternative way of doing the same action.

This PR fixes #59

Link(s)

Screenshot(s)

The warnings look like this:

Screenshot 2020-10-21 at 15 15 41

Checklist:

  • I have thoroughly read the CONTRIBUTING guidelines.
  • I understand my pull request will be thoroughly reviewed at high detail.
  • I understand the work in my pull request will only be available in the next version release of Checka11y.css and not in the current version release.
  • I confirm the work in this pull request is valid according to my findings and is not something for anything personal.
  • I have updated the README and/or features.md where and if applicable (still put an x if you have considered this but thought there was nothing to add or modify).
  • I have added myself to the contributors section in package.json (still put an x if you have considered this but decided not to add yourself).
  • I have checked I have not committed any accidental files.
  • I have tested all the main modern browsers (I.e. Chrome, Firefox, Edge, Safari - please leave this unchecked if there were any browsers listed you could not test and list them in the help section with details why you couldn't test that browser)
  • All new and existing a11y checks still work correctly (compare your local test/index.html to the test/index.html in the master branch).

Help

When HTMLElements use mouse event handlers such as onclick, ondblclick,
onmouseup/down, onmouseenter/leave or onmouseover, without providing the
proper alternatives (i.e. onkeydown/up/press, no or wrong tabindex and
no or wrong role), they could become unreachable via the keyboard.

We therefore should warn users of the danger, but it is ultimately up to
them if they want to ignore it because they might have, for example,
provided some alternative way of doing the same action.

This excludes <a> and <button> elements.

fixes jackdomleo7#59
@jackdomleo7 jackdomleo7 added the a11y feature New feature or request for an a11y check label Oct 21, 2020
@jackdomleo7 jackdomleo7 self-requested a review October 25, 2020 13:47
Copy link
Owner

@jackdomleo7 jackdomleo7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@jackdomleo7 jackdomleo7 merged commit 833bceb into jackdomleo7:master Oct 25, 2020
@tricinel tricinel deleted the feature/non-clickable-elements branch October 26, 2020 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a11y feature New feature or request for an a11y check
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warn when using onclick on non-clickable elements
2 participants