You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Selector, DropdownMenu, and ContextMenu ignore option clicks inside a shadow root #7908
Inside a shadow root, clicking an option in a Selector closes the list without selecting the option. DropdownMenu and ContextMenu share the cause, since they use the same useMenuPress hook. Keyboard selection works.
useMenuPress finds the element under the released pointer with document.elementFromPoint (useMenuPress.ts L366-L367):
For a point inside a shadow root, document.elementFromPoint returns the shadow host, not the option. root.contains(element) is then false, so resolvePoint reports the release as outside the menu, and the hook dismisses the menu instead of activating the option.
I expected the option under the pointer to be selected, as it is outside a shadow root.
Reproduction
Render a Selector inside an open shadow root, for example createRoot(host.attachShadow({mode: 'open'})) with the Astryx CSS adopted into the shadow root.
Open the selector and click an option with the mouse.
The list closes and the value does not change.
With the pointer over an option, the page reports:
document.elementFromPoint(x,y);// the shadow host elementhost.shadowRoot.elementFromPoint(x,y);// the option's <span>
I hit this with Astryx widgets in marimo, which renders each notebook widget inside a shadow root. The same widgets work in JupyterLab, which does not use a shadow root.
A local patch that hit-tests in the menu's own root fixes it:
Activity
Build Astryx from the canary that fixes menu clicks in a shadow root
fix(useMenuPress): hit-test in the menu's own shadow root (meta#7914)
Build Astryx from the 0.7.12 release