KEMBAR78
fix: prevent closing submenu when switching between items by sissbruecker · Pull Request #10152 · vaadin/web-components · GitHub
Skip to content

Conversation

@sissbruecker
Copy link
Contributor

Description

Currently, if a submenu is already opened, then opening a submenu for a different item can result in the items having invalid expanded states. This seems to be a regression from switching to the Lit-based component. There is a timing change which results in opening a submenu executing these steps now:

  • The currently opened submenu is closed
  • The new item is marked as expanded
  • An opened-changed listener fires afterwards and clears the expanded state from the new item
  • Meanwhile the expanded state is never removed from the original item

Previously it seems it ran in a different order where closing the submenu would immediately fire the event so that the old item was marked as not expanded, and then only afterwards the new item was marked as expanded.

Aside from the bug, closing and reopening the submenu also resulted in a worse UX as the opening animation of the submenu ran every time you switched to a different parent item.

This changes the submenu opening logic to not close and reopen the menu, so the opened-changed listener is never triggered from this method. Instead:

  • The old item is marked as not expanded from the same method
  • The submenu is only closed if the new item does not have children
  • The method for updating the submenu runs requestContentUpdate to show the new items (maybe this was why opening and closing was used before)

Fixes #10120

Type of change

  • Bugfix

@sonarqubecloud
Copy link

@web-padawan web-padawan merged commit 8422f1c into main Sep 11, 2025
9 checks passed
@web-padawan web-padawan deleted the fix/prevent-closing-menu-on-hover branch September 11, 2025 11:38
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 25.0.0-alpha10.

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.

[context-menu] Hovering over items results in invalid state

3 participants