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

Add prefer-action-list-item-onselect #211

Merged
merged 9 commits into from
Aug 28, 2024

Conversation

camchenry
Copy link
Contributor

Adds a new recommended lint rule to prevent accessibility issues where developers used onClick for an ActionList.Item component, but should have used onSelect instead, so that it is keyboard accessible. Since this is almost always an accessibility violation in practice, I've enabled it by default and marked it as an error.

This rule is typically auto-fixable as it involves renaming the property from onClick to onSelect, which is sufficient to fix the issue. In some cases, type-checking errors which are not auto-fixable may result since a callback handler may have only expected mouse events. In most cases this can be fixed by adding a MouseEvent | KeyboardEvent type annotation.

@camchenry camchenry requested a review from a team as a code owner August 26, 2024 15:15
Copy link

changeset-bot bot commented Aug 26, 2024

🦋 Changeset detected

Latest commit: 825cda1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
eslint-plugin-primer-react Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@francinelucca francinelucca removed their request for review August 26, 2024 22:08
@siddharthkp siddharthkp merged commit 3f92cd4 into main Aug 28, 2024
8 checks passed
@siddharthkp siddharthkp deleted the camchenry/prefer-onselect-rule branch August 28, 2024 08:55
@primer-css primer-css mentioned this pull request Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create lint rule to prevent passing only onClick to ActionList.Item
3 participants