Repository navigation
fix(sidebar): portal the submenu out of the scrollable menu - #1902
Merged
Merged
Conversation
The child panel rendered inside the fixed, scrollable root menu, so it was only viewport-anchored while nothing on that menu created a containing block. With one present (the reporter's build carries backdrop-filter: blur(22px) saturate(1.55)) Chromium offsets the child by the menu's own position and the menu's scrollWidth jumps from 194 to 1274, which is the reported flying panel plus horizontal scrollbar. Measured directly in Chromium: plain CSS puts the child at the expected (448,299) with no overflow; adding the reported declaration moves it to (1980,410) — exactly the menu offset (900,110). Portal the panel to the body so no ancestor of the menu can offset it, add the pointer-leave guards for the two halves of the portal, and follow the trigger through root-menu scroll and growth.
Owner
|
Independently reproduced this with the real SidebarMenuPanel in isolated Chromium and a backdrop-filter containing block. Old main reports an offset submenu and root scrollWidth 188 versus clientWidth 180; the candidate portals it outside, aligns panelLeft with triggerRight (280), and keeps scrollWidth/clientWidth at 180/180. Child actions still execute. All 10 focused contracts/real Electron worktree-menu journey tests pass, including pointer travel, click and keyboard navigation; Desktop typecheck passes. This repairs the existing placement contract without a design change. Refreshing the PR against current main and proceeding to merge, ignoring CI status as requested. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
Fixes #1896 — the sidebar's second-level menu (Git / copy / danger zone) renders away from its trigger and stretches the menu into a horizontal scrollbar once anything on the root menu creates a containing block for
position: fixeddescendants.Root cause
The child panel is a DOM child of the root menu (
SidebarMenuPanel.tsx), while both areposition: fixed..sidebar-row-menuis alsooverflow-y: autowith amax-height. A fixed child is viewport-anchored only while no ancestor creates a containing block; the moment one appears — the reporter's build carriesbackdrop-filter: blur(22px) saturate(1.55)on.sidebar-floating-menu, and atransform,filterorcontainwould do the same — the child is laid out relative to the menu, soplaceSidebarSubmenu()'s viewport coordinates get the menu's own offset added on top, and the child lands inside the menu's scroll area.Measured in Chromium (not inferred)
I built the exact CSS from
sessions.cssand measuredgetBoundingClientRect()+scrollWidth/clientWidthin Chromium, with and without the reported declaration:scrollWidth / clientWidthbackdrop-filteron the menu1980−448 = 900 and 410−299 = 110 — exactly the menu's own position, matching the reporter's measurement, and
1274is the reported scroll overflow. So on today'smainthe placement works only because no containing-block creator is present; the isolation is accidental. Portaling the child (measured the same way) restores448/299-style placement andscrollWidth === clientWidtheven with the declaration applied.Change
portalToBody, the same helper the root menu already uses fromSidebar.tsx).position: fixed,z-index, ids andaria-controlsare unchanged, so nothing about the visual contract moves.onPointerLeavethat closes only when the pointer left both panels, and the root menu's leave check also accepts the portaled child. React's synthetic leave already follows the React tree through portals (verified in a React 19 + Chromium probe: moving onto the child fires no root leave), so these guards cover native leave sources rather than replacing React's behavior.scrollevent, so the child keeps up when the menu grows asynchronously or is scrolled — today it only reacted to its own size and window resizes.Keyboard behavior is untouched: React events still bubble from the portaled rows to the root menu's
onKeyDown,closest('[role="menu"]')still identifies the child panel, and focus restore still finds the trigger inside the root menu.Verification
test/sidebar-menu-panel.test.mjs— 9/9 pass; three new contracts pin the portal, the leave guards on both sides, and the scroll/size following.test/worktree-menu-user-path.test.mjs(Electron user path) — updated to query the portaled child fromdocument, plus two new steps: moving onto the child keeps it open, leaving both panels closes it. Fixture syntax-checked locally; the Electron run itself is the CI job's (this box has no Electron binary).test/sidebar*.test.mjs— 115/115 pass.tsc --noEmitclean.One commit on
main(541471d).