Skip to content

fix: store composed path for deferred context menu open#9645

Merged
sissbruecker merged 1 commit into
mainfrom
fix/context-menu-store-composed-path
Jul 1, 2026
Merged

fix: store composed path for deferred context menu open#9645
sissbruecker merged 1 commit into
mainfrom
fix/context-menu-store-composed-path

Conversation

@web-padawan

Copy link
Copy Markdown
Member

The context menu target connector opens the menu after a server round-trip: it stores the opening event, dispatches vaadin-context-menu-before-open, and the server later calls back $contextMenuTargetConnector.openMenu, which runs contextMenu.open(storedEvent).

By then the event has finished dispatching, so event.composedPath() returns an empty array. The web component relies on the composed path to resolve the actual opening target inside a shadow root (e.g. a grid cell). With an empty path it falls back to the retargeted event.target (the shadow host), so the menu is positioned against the host instead of the deep element.

This stores the composed path on the event while it is still dispatching, so the web component can resolve the correct target when it opens the menu later.

Changes

contextMenuTargetConnector.js captures e.__composedPath = e.composedPath() in openOnHandler before deferring. The web component reads __composedPath when composedPath() is empty (see the companion web-components change).

Related to vaadin/web-components#12007


🤖 Generated with Claude Code

The context menu is opened after a server round-trip, once the opening
event has finished dispatching and composedPath() returns an empty array.
Store the composed path on the event while it is still dispatching, so the
web component can resolve the target inside a shadow root (e.g. a grid cell)
instead of the retargeted host.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

sonarqubecloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

@sissbruecker sissbruecker added this pull request to the merge queue Jul 1, 2026
Merged via the queue into main with commit 511275a Jul 1, 2026
22 checks passed
@sissbruecker sissbruecker deleted the fix/context-menu-store-composed-path branch July 1, 2026 08:30
web-padawan added a commit that referenced this pull request Jul 1, 2026
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
web-padawan added a commit that referenced this pull request Jul 1, 2026
Co-authored-by: Serhii Kulykov <iamkulykov@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

3 participants