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

Create lint rule to prevent passing only onClick to ActionList.Item #205

Closed
camchenry opened this issue Aug 8, 2024 · 3 comments · Fixed by #211
Closed

Create lint rule to prevent passing only onClick to ActionList.Item #205

camchenry opened this issue Aug 8, 2024 · 3 comments · Fixed by #211

Comments

@camchenry
Copy link
Contributor

camchenry commented Aug 8, 2024

I would like to suggest that we create a lint rule that prevents using only onClick with ActionList.Item and that would auto-fix to use onSelect instead.

Context

I've recently fixed a number of accessibility bugs where behavior was only accessible with the mouse because we passed onClick to an action list item, instead of using the onSelect attribute.

Examples:

While onClick is not completely invalid to put on ActionList.Item, if it is the only means by which an item can be activated, then it creates an inaccessible experience.

Using code search, I can also see some other code examples which might be problematic:

Examples

Code that should be considered invalid by this rule:

<ActionList.Item onClick={...}>

Code that should be considered valid by this rule:

<ActionList.Item onSelect={...}>
<ActionList.Item onSelect={...} onClick={...}>
@camchenry camchenry added the react label Aug 8, 2024
@camchenry camchenry changed the title Create lint rule to prevent passing only onClick to ActionListItem Create lint rule to prevent passing only onClick to ActionList.Item Aug 8, 2024
@siddharthkp
Copy link
Member

@lesliecdubs
Copy link
Member

👋 @camchenry thanks for proposing this! Are you interested in upstreaming it to Primer?

@camchenry
Copy link
Contributor Author

@lesliecdubs Sure! If I have some time this week, I can work on upstreaming this rule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants