Skip to content

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

@camchenry

Description

@camchenry

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={...}>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions