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

md-menu-item of type="button" should click on keyboard selection #5577

Open
austinw-fineart opened this issue Apr 11, 2024 · 2 comments
Open

Comments

@austinw-fineart
Copy link

Description

In the same way that a click is triggered for anchors on keyboard selection, I would expect the same to apply for buttons as well. However that is not the case. Instead, you have to handle the close-menu event manually to produce the same effect.

Compare between using mouse and keyboard to select from two kinds of menu:
Example Playground

Also notice how anchors only get clicked on Enter but not Space which matches their native behavior but not so much the menu spec. The inconsistency irks me a bit but meh. As an aside, I feel like handling selection from a menu is the most essential part of using it so there should be an easier way to go about all this.

@asyncLiz
Copy link
Collaborator

I think the culprit is the menu item controller's keydown handler, which stops the space/enter keydowns from making a click.

@e111077 may know a bit more about that controller, but that'd be a good place to start debugging.

@e111077
Copy link
Contributor

e111077 commented Apr 12, 2024

The initial reasoning is that a click will cause the menu to close / open submenu via click selection. This would then likely trigger the close twice and cause some visual jank.

Additionally, by marking it as defaultPrevented == true, we prevent the menu's typeahead functionality from triggering on "space" as the first button pressed.

We might be able to add some likely non-trivial logic / rewrite here to solve this. Perhaps another marker other that preventDefault, but that may degrade the DX of "just call preventDefault on any event to opt out of menu events"

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

No branches or pull requests

3 participants