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

fix: only focus parent item if sub-menu contained focus #7519

Merged
merged 1 commit into from
Jul 9, 2024

Conversation

web-padawan
Copy link
Member

Description

Fixes vaadin/flow-components#6386

Updated the context-menu to check if the sub-menu contained a focused item before closing it:

  • If that's true, the focus is moved to the corresponding parent item (and the outline is preserved).
  • Otherwise, the overlay part receives focus, so that we can still handle keydown for arrow keys.

I think this makes more sense than a workaround with focusing the item without showing outline.

Type of change

  • Bugfix

Note

See video below for the updated behavior:

Hover

Parent / child item is not focused when opening / closing sub-menu on hover:

context-menu-hover.mp4

Keyboard

Parent item is focused after closing a sub-menu with a focused child item:

context-menu-focus.mp4

Copy link

sonarqubecloud bot commented Jul 8, 2024

Copy link
Contributor

@DiegoCardoso DiegoCardoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@web-padawan web-padawan merged commit d6be7a4 into main Jul 9, 2024
9 checks passed
@web-padawan web-padawan deleted the fix/context-menu-parent-item-focus branch July 9, 2024 07:00
web-padawan added a commit that referenced this pull request Jul 9, 2024
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
web-padawan added a commit that referenced this pull request Jul 9, 2024
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 24.5.0.alpha5 and is also targeting the upcoming stable 24.5.0 version.

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

Successfully merging this pull request may close these issues.

MenuBar SubMenuItems render the focus ring on hover
4 participants