Skip to content

<ActionList.Item>: event in onClick can be canceled, but it cannot be canceled in onSelect #3162

@gr2m

Description

@gr2m

Description

Calling event.preventDefault() in the onSelect handler of ActionList.Item does not prevent closing the context menu. But it does work in onClick.

Screen.Recording.2023-04-12.at.11.57.00.AM.mov

I want to delay closing the context menu in order to give a user a visual feedback when something gets copied in their clipboard

Screen.Recording.2023-04-12.at.11.59.47.AM.mov

It works when using the onClick handler. But that makes it inaccessible to keyboard users.

I would expect that calling event.preventDefault() in the onSelect handler would prevent closing the menu so that I can do it manually when selecting the item with the mouse or they keyboard.

Steps to reproduce

https://stackblitz.com/edit/github-primer-action-test?file=App.tsx

Version

35.24.0

Browser

Chrome

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions