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

ActionMenu keyboard navigation: pressing space key on focused menu item should trigger the action #2253

Closed
cbliard opened this issue Sep 20, 2023 · 4 comments · Fixed by #2260

Comments

@cbliard
Copy link

cbliard commented Sep 20, 2023

When a user opens the ActionMenu dropdown by pressing space or enter, the first item is focused and the focus can be moved with the arrow keys, but pressing space does not properly trigger the associated action.

This can be experienced on LookBook ActionMenu with_actions example. On this one, Enter works as expected but not space key:

  • Click twice on the "Trigger" button to show and hide it so that it gets the focus
  • Press Down arrow key, the menu listing actions is displayed and the first menu item, "Alert", is focused (this one is a <button>)
  • Press Space, the menu is hidden (it should have triggered the alert)
  • Press Space again, the menu is shown again and the alert action is triggered (the action should not trigger at this point)

It can also be experienced on other examples like links or opens_dialog. For these two, space key never triggers the action, even on second press.

@lesliecdubs
Copy link
Member

Thanks for the report, @cbliard!

@TylerJDev, I can confirm the behavior described in this issue. After opening ActionMenu, pressing "enter" will trigger the action menu item behavior, while pressing "space" does not. Can you confirm whether this is an accessibility violation (e.g., that "space" also needs to trigger the action), or if these behaviors are only required to occur on "enter"?

@lesliecdubs lesliecdubs self-assigned this Sep 20, 2023
@lesliecdubs lesliecdubs added the a11y eng Requires input from PVC accessibility engineering experts label Sep 20, 2023
@lesliecdubs lesliecdubs removed their assignment Sep 20, 2023
@TylerJDev TylerJDev self-assigned this Sep 21, 2023
@TylerJDev
Copy link
Member

Hey @cbliard, thanks for bringing this up!

We have a PR which should partially fix this issue. This PR will allow menu items which were originally links, to be triggered with "Space" in addition to the "Enter" key.

Here's an example of the ActionMenu with links, but stemming off the draft PR's branch:

As for the other examples, I see we don't respect the "Space" key when triggering a menu item that was originally a button. If I had to take a guess, I believe this is because we rely on the native functionality of the button to trigger the event. With buttons, space will only trigger the event on key up which only fires after the menu has already closed.

@lesliecdubs, I can confirm this is an issue, but shouldn't require much lift to fix.

@lesliecdubs
Copy link
Member

Thanks @TylerJDev 🙇🏻‍♀️

I will bring this to the PVC working group to discuss and see if we can revive #2199 for merge, as well as addressing the remaining work here, which sounds like it is to respect the "Space" key when triggering a menu item that was originally a button (though please correct me if I got that wrong!).

@lesliecdubs lesliecdubs removed the a11y eng Requires input from PVC accessibility engineering experts label Sep 21, 2023
@cbliard
Copy link
Author

cbliard commented Oct 11, 2023

Thanks a lot for fixing this!

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.

4 participants