Repository navigation
Description
Context
Part of #2576. Easier after #2578, which settles the roles; it does not wait on it.
Five anchored menus and pickers are hand-rolled: an absolutely positioned div at z-popover, plus document mousedown/pointerdown and keydown listeners for dismissal:
| Surface | Code |
|---|---|
| Share menu | (ShareMenu, packages/ui-react/src/components/share/share-menu.tsx:53-72) listeners, :124-143 panel |
| Provider picker + desktop Attach | (Composer, packages/ui-react/src/components/chat/composer.tsx:332-352) shared listeners gated on matchMedia("(min-width: 900px)"). Panels at packages/ui-react/src/components/chat/composer-view.tsx:191-204 |
| Model picker (desktop) | (ModelPicker, packages/ui-kit/src/chrome/ModelPicker.tsx:59-67) Escape and a hand-written Tab wrap, :157-160 the positioned box |
| Session row overflow | (SessionOverflow, packages/ui-react/src/components/chat/session-list.tsx:311-352) |
| Pending follow-up reveal | (PendingFollowUps, packages/ui-kit/src/chrome/PendingFollowUps.tsx:132-144) outside-tap listener, :255-295 hover/focus/tap reveal |
Costs today:
- About 70 lines of listener code.
- No Android back dismissal.
- The panels are clipped by any ancestor that contains paint. (
.chat-message-body,packages/ui-react/src/theme.css:651-667) had to narrowcontent-visibility: autoto the message body because "the share dropdown opens past the bottom of its message".
popover="auto" gives light dismiss, Escape and close-request (Android back) dismissal, and top-layer rendering with no clipping. CSS anchor positioning places the panel without measuring. Support: popover Chrome Android 114, Samsung 23, Firefox Android 125. anchor-name 125/27/147. position-try-fallbacks 128/28/147.
Guide ui-atoms/viewport-aware-dropdowns and ui-behaviors/declarative-dialog-popover-control. The guides' polyfills are not allowed under the epic's policy.
Recorded decision — 2026-10-22
The maintainer ruling approves auto top-layer popovers for Share, Provider picker, desktop Attach, desktop ModelPicker and Session overflow, amending D54’s panel/popover order. ModelPicker has no Tab trap: Tab out closes it and focus continues forward. PendingFollowUps is a manual top-layer popover driven by existing hover/focus/tap handlers, with one retained outside-tap listener and explicit Escape/close-request handling. Unsupported anchor positioning uses the accepted bottom-docked geometry at every width, full width up to max width, centred above the safe area. All four choices are settled.
Scope
Implement the accepted branch:
- Each surface except PendingFollowUps renders
popover="auto", opened withshowPopover()/togglePopover()from its trigger. Itstoggleevent keeps React state in sync, so light dismiss, Escape and Android back all updateopen. Remove the matching document dismissal listeners. PendingFollowUps uses popover="manual", retains its one outside-tap listener and adds Escape/close-request dismissal. ModelPicker removes the Tab wrap; focus-out closes it without trapping or stealing the next focus target. - Position with CSS anchor positioning. Derive each anchor name from
useId()so instances never collide, and useposition-try-fallbacks: flip-block. Under@supports not (anchor-name: --a), use the ruled fallback geometry. No polyfill. - Feature-detect
popoverwith"popover" in HTMLElement.prototype. Where it is missing (none of the current targets), keep today's positioneddivand listeners. - After Share moves to the top layer, widen
content-visibility: autointheme.css:651-667to the whole message, as its comment anticipates, and update that comment. - Amend the D54 layer table and the
@layersblock in overlays.md in the same PR.
Out of scope
- The desktop dictation popover (
packages/ui-react/src/components/voice/dictation-sheet.tsx). It must not be dismissable while draining, which light dismiss would break. - Phone sheets (
Overlay variant="sheet"), which are already native modals. - The graph node list (
packages/ui-react/src/components/graph/graph-scene.tsx:694-697), which ui-react: keep phone graph list controls usable beside selected-note details #1919 owns. - Changing roles (ui-react: Attach and Share popovers claim role=menu without the menu keyboard contract #2578).
- New motion (D54 "Closing is instant").
Acceptance criteria
- The maintainer has ruled on all four choices.
- Record the accepted layer/fallback/manual-popover amendment in overlays.md and its @layers block.
- If yes: every surface in the table opens in the top layer. Each closes on outside tap, on Escape and on a close request, with
openstate in sync and focus returned to its trigger. All automatic surfaces remove document dismissal listeners. PendingFollowUps alone retains its one outside-tap listener and explicit close-request handling. Tests cover its outside tap, Escape and Android Back. ModelPicker Tab-out closes it and continues focus forward. - If yes: a real-Chromium test opens Share inside a long message and inside an open Files panel, and asserts that the panel is fully visible and above the Files panel. It fails on the current tree. A second run forces the
@supports not (anchor-name)path through an injected stylesheet override and asserts the fallback geometry. - If yes:
content-visibilityis widened, and a long-transcript layout test shows no clipping of Share. - Visual baselines change only where the ruling approves.
Verification
bun run test packages/ui-kit packages/ui-react
node scripts/visual.mjs --project=visual --project=subjects
node scripts/visual.mjs --project=ui-react-layout
node scripts/visual.mjs --project=rail-fine --project=rail-coarse
bun run typecheck
bun run lint
bun run check:pr --base origin/mainContract impact
- This touches the integration contract, so it needs the
contractlabel, aCONTRACT:commit prefix, and the doc updated in the same commit. - This changes a published package's behaviour, so it needs a changeset.
ModelPicker and PendingFollowUps props stay as they are. LAYERS.popover and z.popover are present in api-report/ui-kit.txt and therefore supported exports. Use the maintainer-approved deprecation path: preserve those exports and their existing values/CSS variable while internal users move to the top layer; document their deprecated status. Removing them is outside this scoped migration and needs its own prior breaking ruling, contract handling and migration. Do not retire --bk-z-popover while the supported z.popover export still refers to it.
2026-10-22 readiness reconciliation at inspected main aa8c896: folded the later maintainer ruling into the active specification and criteria. Earlier proposal/needs statements above describe their dated review stage. The accepted brief has no remaining needs prerequisite; add agent-ready. No implementation or runtime completion is claimed.
Activity
schlessera commentedon Oct 22, 2026
Maintainer ruling
popover="auto". This covers Share, Provider picker, desktop Attach,ModelPickerand Session row overflow.z-popover20 underz-panel40.--bk-z-popoveris retired if nothing else uses it.z.popover/LAYERS.popoverexport (tokens.ts:1319). If removing it is a supported-API removal, it needscontractandbreakinghandling. Otherwise, deprecate it first and remove it later.ModelPickerbecomes<div role="dialog" popover="auto">. It light-dismisses and has no focus trap. The hand-written Tab wrap is removed. Tabbing out of the picker closes it (light dismiss on focus-out), and focus continues to the next control.PendingFollowUpsbecomespopover="manual", shown and hidden withshowPopover()/hidePopover()from the existing hover, focus and tap handlers. It renders in the top layer with no clipping, and hovering never light-dismisses it.manualpopover has none natively. Add a close-request handler so Android back hides it too.mousedown,pointerdownorkeydownlisteners.anchor-nameis unsupported (@supports not (anchor-name: --a)): the popover docks to the bottom of the viewport, full width up to the popover's max width and centred, aboveenv(safe-area-inset-bottom). This geometry is accepted at every width, including desktop, where it appears away from its trigger.overlays.mdamendment (D54 layer table row)Also update the
@layersblock in the same PR. Closing stays instant (D54). No new motion.Acceptance criteria adjustments
PendingFollowUpskeeps one outside-tap listener and adds close-request handling. A test asserts that outside tap, Escape and Android back each hide it.ModelPickertest asserts there is no Tab trap, and that Tab out of the picker closes it and moves focus forward.@supports not (anchor-name)run asserts the bottom-dock geometry.content-visibilityis widened to the whole message.schlessera commentedon Oct 22, 2026
2026-10-22 readiness reconciliation: folded the maintainer ruling into the body, replacing the unresolved-choice specification and aligning scope/criteria with the accepted branch. The remaining work is explicitly scoped; add agent-ready. Preserve priority, native parent, assignment and release attribution. This is issue preparation, not implementation, runtime proof or delivery.