Skip to content

refactor: update menu-bar submenu to open synchronously #8909

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

web-padawan
Copy link
Member

Description

Depends on #8908 (this is an independent change but some Tab navigation tests would fail until that PR is merged).

Wrapping opening submenu event with requestAnimationFrame() was added in vaadin/vaadin-menu-bar#12. It seems unnecessary since there is no need to delay opening overlay (the very first revision at vaadin/vaadin-menu-bar@3bdc279 had an additional before-open event with some logic, but that was changed in a subsequent commit).

Tested this change with Flow components and it seems to make ITs more reliable in terms of timeouts.

Type of change

  • Refactor

Copy link

sonarqubecloud bot commented Apr 4, 2025

@@ -59,7 +59,6 @@ snapshots["menu-bar basic"] =
snapshots["menu-bar overlay"] =
`<vaadin-menu-bar-overlay
opened=""
right-aligned=""
Copy link
Member Author

Choose a reason for hiding this comment

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

Something was wrong about this snapshot having both right-aligned and start-aligned, seems like the right-aligned was set by __alignOverlayPosition() from ContextMenuMixin since we used to delay setting positionTarget (now it's set synchronously so the above logic doesn't run).

Comment on lines -957 to -962
// After changing items, buttons are recreated so the old button is
// no longer in the DOM. Reset position target to null to prevent
// overlay from closing due to target width / height equal to 0.
if (overlay.positionTarget && !overlay.positionTarget.isConnected) {
overlay.positionTarget = null;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

This was needed before we added initial sync rendering in #8290 - back then, the positionTarget was only set to button after waiting for updateComplete. This is no longer needed, we can set it immediately.

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

Successfully merging this pull request may close these issues.

1 participant