Repository navigation
feat(usePopover): anchorOutOfViewBehavior hides a popover while its anchor is out of view (AST-116 FR7, FR8) - #11122
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Approval waits on an engineering owner deciding the direction for anchorOutOfView, whose only governing text is the draft spec:AST-113 FR7, FR8 and DEC-3, including its name (architecture:public-component-api INV2 asks for a <thing>Behavior prop, and AST-113 OQ2 leaves the name open). An engineering owner records the decision by approving AST-113 or by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
These need changes either way:
- With
anchorOutOfView="hide", focus inside the open popover drops to the page body when it hides and is not restored when the anchor returns (in Chromium, an inline editor's input loses focus on a wheel scroll), which breakscomponent:PopoverAR3 and contradicts the comment atuseLayer.tsx:72-73. - The changeset says
'hide'stops a popover from floating over content when its anchor scrolls out of a scrolling panel, but in Chromium the base already neither paints nor hit-tests that popover (position-visibility: anchors-visible), so narrow the wording to the page-scroll case the change actually affects. - An anchor replaced while open is re-observed by bumping
anchorGenerationin the trigger ref to re-run an Effect (useLayer.tsx:1841-1843,:2175), when the unobserve and observe belong in that callback ref, as the keep-clear observers already do at:1849-1860.
[Automated review]
fa323a6 to
3cf6201
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner deciding the direction and the name for anchorOutOfView, whose only governing text is the draft spec:AST-113 FR7, FR8 and DEC-3 (architecture:public-component-api INV2 asks for a <thing>Behavior prop, and AST-113 OQ1 lists the names as proposed). An engineering owner records the decision by approving AST-113 or by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
These need changes either way:
- With
anchorOutOfView="hide", focus inside the open popover drops to the page body when it hides and is not restored when the anchor returns (Chromium and Firefox, page and panel scroll), which breakscomponent:PopoverAR3 and contradicts the comment atuseLayer.tsx:72-73. - An anchor replaced while open is re-observed by bumping
anchorGenerationin the trigger ref to re-run an Effect (useLayer.tsx:1841-1843,:2175), when the unobserve and observe belong in that callback ref (architecture:react-component-runtimeINV6), as the keep-clear observers already do at:1849-1861.
The earlier note on the changeset's scrolling-panel wording is withdrawn: in Firefox the base popover does float over the page when its anchor leaves a scrolling panel.
3cf6201 to
e91b0ff
Compare
b905360 to
199db1d
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner deciding the direction and the name for anchorOutOfView, whose only governing text is the draft spec:AST-116 FR7, FR8 and DEC-3 (the record formerly numbered AST-113). architecture:public-component-api INV2 asks for a <thing>Behavior prop, and AST-116 OQ1 lists the name as proposed. An engineering owner records the decision by approving AST-116 or by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.
These need changes either way:
- With
anchorOutOfView="hide", focus inside the open popover drops to the page body when it hides and is not restored when the anchor returns (Chromium and Firefox, page and panel scroll), which breakscomponent:PopoverAR3 and contradicts the comment atuseLayer.tsx:72-73. - An anchor replaced while open is re-observed by bumping
anchorGenerationin the trigger ref to re-run an Effect (useLayer.tsx:1841-1843,:2175), when the unobserve and observe belong in that callback ref (architecture:react-component-runtimeINV6), as the keep-clear observers already do at:1849-1861.
e91b0ff to
e18f427
Compare
199db1d to
4a33324
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner deciding the new usePopover option anchorOutOfViewBehavior, whose only governing text is the draft spec:AST-116 FR7, FR8, DEC-3 and DEC-8, which are not on main. An engineering owner records that decision by approving those claims or by commenting /approve-spec <full head SHA> here, which the author may do as an engineering owner; it should also settle the 'stay' value name and where focus goes when the surface hides.
These need fixing whatever the decision:
- With
'hideWhileOutOfView',visibility: hiddendrops focus from a control inside the open popover to the page body and never restores it, so someone typing in a row editor loses their place when the row scrolls away (useLayer.tsx:74-77,:2291;component:PopoverAR3). - A replaced anchor is re-observed by bumping
anchorGenerationstate to re-run an Effect; move the unobserve and observe into thecontextRefcallback ref, as the keep-clear observers already are, and drop the state (useLayer.tsx:1841-1843,:2175). - Newly live check:
hidesWithAnchorRef.current = hidesWithAnchorwrites a ref during render; useuseCommittedRef(onmain) or pass the flag through the ref callback's dependencies (useLayer.tsx:1232).
Approval also needs the first-load gzip deltas that INV10 asks for: a page that renders Popover without the option, and the four reference pages, base against head.
Claims and files checked
Review mode: full; reason: rebase
- Claim:
usePopovertakesanchorOutOfViewBehavior: 'stay' | 'hideWhileOutOfView', andPopoverPropsis unchanged — verified (usePopover.tsx:185; the generated API delta has one row). - Claim:
'stay'is the default and today's behavior — verified (usePopover.tsx:481; the "stays by default" test; existing suites pass). - Claim: with
'hideWhileOutOfView'the popover is hidden and takes no pointer input while the anchor is out of view — verified (useLayer.tsx:74-77,:2291; jsdom test; Chromium probe). - Claim: out of view covers the viewport and any scrolling ancestor — verified (observer with no root,
useLayer.tsx:2167; Chromium panel probe); the removed-anchor case — unverified (no test or browser check). - Claim: it stays open, fires no
onHideand shows again in place — verified (test; Chromium probe shows the popover still open and visible again on return). - Claim: the hide reads no layout per scroll frame and moves nothing — verified (the observer callback only sets state; the style adds visibility and pointer-events only).
- Claim: a layer with the internal flag re-observes a replaced anchor, and other layers still render once on replacement — verified (
useLayer.tsx:1841-1843,:2175; the third new test;useLayer.test.tsx:3716-3719passes). - Claim:
visibility: hiddenkeeps the box and its place in the top layer — verified; the code comment's "focus order hold" — false (Chromium moves focus to the body). - Claim: an anchor scrolled out of a scrolling panel leaves the popover floating over unrelated content today — verified in Firefox in an earlier run; in Chromium the base already stops painting it.
- Claim: the release note's description of the option, its default and that it stays open — verified against the code.
- Claim: the focused vitest run, typecheck and lint pass — verified (8 files, 294 tests; tsc and eslint clean); the whole-project run on another pull request was not checked.
.changeset/popover-anchor-out-of-view.md— clear.packages/core/src/Layer/useLayer.tsx— three findings above, plus two comment notes.packages/core/src/Popover/PopoverAnchorOutOfView.test.tsx— clear; it cannot show the focus loss.packages/core/src/Popover/usePopover.doc.mjs— clear.packages/core/src/Popover/usePopover.tsx— clear.
…nd focus return (draft)
…e for every layer
…resses, named supersessions, accessibility requirements
… order, hidden modal surface, focus-return eligibility, named compatibility changes
…og, DropdownMenu, layer-runtime and overlay-dismissal
…ePress on usePopover only (DEC-8)
d1fafde to
1e95c9b
Compare
73ea344 to
32ef02e
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner deciding the new usePopover option anchorOutOfViewBehavior: its only governing text is spec:AST-116 FR7, FR8, AR1, DEC-3 and DEC-8, and that record is not on main yet (#11112 is still a draft). An engineering owner records the decision by merging #11112 or by commenting /approve-spec <full head SHA> here, which the author may do as an engineering owner; the decision should also settle the 'stay' value name and the documented AR1 gap for a popover with neither a focusable anchor nor a trigger.
These need fixing whatever the decision:
- The option is off by default but adds 491 B gzip of first-load JavaScript to a page that renders Popover without it and 510 B to the menu page, over the 0.3 KB that
architecture:component-import-boundariesINV10 allows, mostly through the staticutils/focusReturnimport atusePopover.tsx:36, so move the hide-time focus move behind its own import or a deferred load and report the per-page deltas again. - Miss: focus moves to the anchor only when it is a tab stop (
usePopover.tsx:690-691) although the release note and the JSDoc promise "the anchor when it takes focus", and an anchor that is chosen but refuses focus, such as a disabled button, gets no fallback to the trigger, so test focusability as the shared focus path does and retry with the trigger when the first move fails, or narrow the wording to "a tab stop".
The four blocking findings from the previous round are fixed at this head. Non-blocking notes on comment wording and on keeping modality tracking active for the shared focus path are inline.
Claims and files checked
Review mode: full; reason: rebase
- Claim:
usePopovergainsanchorOutOfViewBehavior: 'stay' | 'hideWhileOutOfView'andPopoverPropsis unchanged — verified (usePopover.tsx:210; the generated API delta has one row). - Claim:
'stay'is the default and today's behavior — verified (usePopover.tsx:522; "stays by default" passes on the base and the head). - Claim: with
'hideWhileOutOfView'the popover is hidden and takes no pointer input while its anchor is clipped by the viewport or a scrolling ancestor, or removed — verified (useLayer.tsx:88-91,:2618; tests; Chromium). - Claim: it stays open, fires no
onHide, and shows again in place — verified (tests; Chromium, with the typed text kept and the same position). - Claim: the hide uses the runtime's existing anchor observation, reads no layout per scroll frame and moves nothing — verified (the observer callback sets state and moves focus; the class writes visibility and pointer events only).
- Claim: the governing record is proposed and not on
mainyet — verified. - Claim: a layer with the internal flag re-observes a replaced anchor, and other layers keep rendering once on a trigger swap — verified (the replaced-anchor test fails on the base; the existing layer suite passes).
- Claim:
visibility: hiddenkeeps the box and its place — verified (the hidden layer keeps its rectangle and stays open in Chromium). - Claim: anchors-visible CSS does not hide a top-layer layer on a page scroll — verified against the layer viewport record.
- Claim: the new tests cover the hide, the default and a replaced anchor, and the existing layer test passes unchanged — verified (7 new tests pass; 5 fail on the base).
- Claim: the earlier three-engine browser run of the older prop shape — not re-run; Chromium was checked at this head.
- Claim: focused tests, typecheck and lint pass — verified (9 files, 330 tests; typecheck and lint clean); the top-of-stack run belongs to another pull request and was not checked.
- Claim: the focus move goes through the shared focus-return path and the local loop is gone — verified (
usePopover.tsx:688-701). - Claim: with neither a focusable anchor nor a trigger, focus falls to the body, a gap line says so, and the verification row drops that case — verified (record gap line and row; Chromium).
- Claim: the observer keeps the node it watches, so a ref anchor removed and later replaced is unobserved first — verified (
useLayer.tsx:2125-2131). - Claim: the removed-anchor test opens once and fails on the base — verified.
- Claim: this pull request's first-load deltas (docs +147, form +138, menu +510, table +171, popover +491) — verified within 2 B; over the allowance on the popover and menu pages (finding).
- Claim: the shared module becomes always-loaded later in the stack, so the stack total is unchanged — not checked; it covers other pull requests.
- Claim: public text carries no internal context — verified.
- Claim: release note for the option — verified.
- Claim: release note for the focus move, "to the anchor when it takes focus" — false for an anchor that takes focus without being a tab stop (finding).
.changeset/popover-anchor-out-of-view.md— clear..changeset/popover-hidden-focus.md— the focus-target wording finding.docs/architecture/layer-runtime.md— its new cross-reference names a record that is not onmain(part of the owner decision).docs/specs/AST-116-popover-anchoring/spec.md— waits on the owner decision; the gap line and row are consistent with the code.packages/core/src/Layer/useLayer.tsx— clear apart from two comment notes.packages/core/src/Popover/PopoverAnchorOutOfView.test.tsx— clear.packages/core/src/Popover/usePopover.doc.mjs— clear.packages/core/src/Popover/usePopover.tsx— the first-load size and focus-target findings, and two non-blocking notes.
| }, [onShow]); | ||
|
|
||
| // Core layer for popover positioning | ||
| // Filled in once the content ref exists; the layer calls it as the surface |
There was a problem hiding this comment.
Non-blocking (INV29): the existing // Core layer for popover positioning above now heads these anchorHiddenRef lines instead of the useLayerInternal call. Move this block above that comment.
| {preventScroll: true}, | ||
| ); | ||
| }; | ||
| useCommittedRefInto(anchorHiddenRef, moveFocusOutOfHiddenSurface); |
There was a problem hiding this comment.
Non-blocking: moveFocusLeftBehind asks its caller to keep modality tracking active (utils/focusReturn.ts:66-68). usePopover does not, so on a page where nothing else tracks it, the store keeps its 'keyboard' default and the move is a plain focus(), leaving the ring to the browser instead of architecture:interaction-modality INV1's last-input rule. Consider useInteractionModalityTrackingFor(contentRef, hidesWithAnchor), loaded with the deferred feature so it does not add to INV10's count.
1e95c9b to
e08d149
Compare
32ef02e to
25310be
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner deciding the new usePopover option anchorOutOfViewBehavior: its only governing text, spec:AST-116 FR7, FR8, AR1, DEC-3 and DEC-8, is approved on #11112 at that pull request's head but is not on main, and this pull request edits the record again (the AR1 verification row and gap, and the layer-runtime INV12 cross-reference). An engineering owner records the decision by commenting /approve-spec <full head SHA> here, which the author may do as an engineering owner.
These need fixing whatever the decision:
- The option is off by default but adds 499 B gzip of first-load JavaScript to a page that renders Popover without it and 518 B to the menu page, over the 0.3 KB that
architecture:component-import-boundariesINV10 allows, mostly through the staticutils/focusReturnimport atusePopover.tsx:36-40, so move the hide-time focus move behind its own import or a deferred load and report the per-page deltas again. - Miss: an
<svg>anchor that can take focus, which AST-116 FR2 accepts, is skipped becausetakesFocusaccepts only HTML elements (usePopover.tsx:697-698), so focus goes to the trigger although the release note, the JSDoc and the docs promise "the anchor when it can take focus"; accept SVG elements there with a test, or narrow the three texts to an HTML anchor.
The previous round's focus-target finding is fixed; non-blocking notes on modality tracking and comment wording stay open inline.
Claims and files checked
Review mode: full; reason: rebase
- Claim:
usePopovergainsanchorOutOfViewBehavior: 'stay' | 'hideWhileOutOfView'andPopoverPropsis unchanged — verified (usePopover.tsx:215; the generated API delta has one row). - Claim:
'stay'is the default and today's behavior — verified (usePopover.tsx:527; "stays by default" passes on the base and the head). - Claim: with
'hideWhileOutOfView'the popover is hidden and takes no pointer input while its anchor is clipped by the viewport or a scrolling ancestor, or removed — verified (useLayer.tsx:88-91,:2618; tests; Chromium and Firefox with the anchor clipped by a panel). - Claim: it stays open, fires no
onHide, and shows again in place — verified (tests; in Chromium and Firefox it stays open and keeps the typed text). - Claim: the hide is driven by the existing anchor observation, reads no layout per scroll frame and moves nothing — verified (
useLayer.tsx:1355-1366,:2470-2502). - Claim: an inline editor floats over unrelated content when its anchor scrolls out of a panel — verified in Firefox; Chromium already left it unpainted on the base, with focus still inside it.
- Claim: the governing record is proposed, not on
main, and an engineering owner approved its pull request's head — verified. - Claim:
takesFocusAsIsis the existing inline test, with no behavior change there — verified (focusReturn.ts:97-117; the focus-return suite passes). - Claim: a layer with the internal flag re-observes a replaced anchor, and other layers keep their released render behavior — verified (the replaced-anchor test fails on the base; the existing layer suite passes).
- Claim:
visibility: hiddenkeeps the box and its place — verified (the editor returns to the same place in both engines). - Claim: anchors-visible CSS does not hide a top-layer layer on a page scroll — verified against the layer viewport record.
- Claim: the new tests cover hide, default and a replaced anchor, and the existing layer test passes unchanged — verified (9 new tests pass; 7 fail on the base).
- Claim: earlier three-engine browser run of the older prop shape — not re-run; Chromium and Firefox were checked at this head, WebKit was not.
- Claim: focused tests pass, typecheck and lint are clean — verified (10 files, 370 tests; typecheck and lint clean); the top-of-stack suite run belongs to another pull request and was not checked.
- Claim: focus moves to the anchor when it can take focus (a tab stop, a
tabindex, an editable region, a focusable control), else to the trigger — verified for HTML anchors; false for an SVG anchor that can take focus (finding). - Claim: an anchor that refuses focus, such as a disabled button, hands the move to the trigger — verified (test; Chromium and Firefox).
- Claim: the JSDoc, docs and release note say "the anchor when it can take focus, else the trigger" — the wording is there; false for SVG anchors (finding).
- Claim: the named new tests and the
takesFocusAsIssuite exist and pass — verified (they fail on the base). - Claim: this pull request's first-load deltas (docs +147, form +138, menu +518, table +168, popover +499) — verified within 1 B; over the allowance on the popover and menu pages (finding).
- Claim: a later pull request makes the shared module always-loaded, so the stack total does not change — not checked; it concerns other pull requests.
- Claim: public text carries no internal context — verified.
- Release note for the option — verified.
- Release note for the focus move — false for SVG anchors (finding).
.changeset/popover-anchor-out-of-view.md— clear..changeset/popover-hidden-focus.md— the SVG anchor wording finding.docs/architecture/layer-runtime.md— its cross-reference names a record that is not onmain(part of the owner decision).docs/specs/AST-116-popover-anchoring/spec.md— waits on the owner decision; the AR1 gap line and row match the code.packages/core/src/Layer/useLayer.tsx— clear apart from two comment notes.packages/core/src/Popover/PopoverAnchorOutOfView.test.tsx— clear.packages/core/src/Popover/usePopover.doc.mjs— the SVG anchor wording finding.packages/core/src/Popover/usePopover.tsx— the first-load size and SVG anchor findings, and two non-blocking notes.packages/core/src/utils/focusReturn.test.ts— clear.packages/core/src/utils/focusReturn.ts— clear.
| import { | ||
| moveFocusLeftBehind, | ||
| noteFocusWithin, | ||
| takesFocusAsIs, | ||
| } from '../utils/focusReturn'; |
There was a problem hiding this comment.
This static import puts noteFocusWithin, moveFocusLeftBehind, takesFocusAsIs and the temporary tab-stop map into every page that renders Popover or DropdownMenu, whether or not anchorOutOfViewBehavior is set. Measured with the option unused: the Popover page grows 499 B gzip and the menu page 518 B, over the 307 B that architecture:component-import-boundaries INV10 allows for an optional feature. Suggested fix: load the hide-time focus move only when anchorOutOfViewBehavior is 'hideWhileOutOfView' (its own import, INV7, or a deferred load, DEC-1), then report the per-page deltas again.
…in usePopover over INV10's allowance; INV10 names the exception
…nchor is out of view, and focus inside it moves out (spec:AST-116 FR7, FR8, AR1)
e08d149 to
6dcfdc9
Compare
25310be to
48a1e5f
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner deciding the new usePopover option anchorOutOfViewBehavior: its only governing text, spec:AST-116 FR7, FR8, AR1, DEC-3, DEC-8 and DEC-9, is not on main yet, and this pull request also edits that record and architecture:layer-runtime INV12. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request (the author may, as an engineering owner), or this pull request waits for the revised AST-116 its description mentions. What must be settled: the option and its values, the hide-time focus move, the record edits, and the first-load cost over architecture:component-import-boundaries INV10 (499 B gzip on the Popover page and 518 B on the menu page with the option unused).
This needs fixing either way:
- Miss: a
'hideWhileOutOfView'popover opened while its anchor is already clipped by a scrolling panel shows for two frames before it hides, and focus passes through it, because the opening read atuseLayer.tsx:2475-2481checks only the viewport; clip that read by the anchor's scrolling ancestors and add a test that opens with the anchor clipped.
Claims and files checked
Review mode: full; reason: rebase
- Claim,
'stay'is the default and keeps today's behavior: verified (usePopover.tsx:527; "stays by default" passes on base and head). - Claim, the hidden popover takes no pointer input while its anchor is clipped by the viewport or a scrolling ancestor, or removed: verified (
useLayer.tsx:88-91,:2618; tests; Chromium and Firefox runs). - Claim, it stays open with no
onHideand shows again in place: verified (tests; the layer stays:popover-openand keeps typed text in both engines). - Claim, the hide uses the existing observer, reads no layout per scroll frame and moves nothing: verified (
useLayer.tsx:2486-2492); the read before the first frame misses scrolling-ancestor clips (finding above). - Claim, the Popover component's props are unchanged: verified (the API comparison lists only the hook option).
- Claim, the exported focusability helper is the old inline test with no behavior change: verified (
focusReturn.ts:98-105is the exact negation of the removed check; the existing suite passes). - Claim, layers without the internal flag keep their released render behavior: verified (the rebind is gated at
useLayer.tsx:2124-2133;useLayer.test.tsxpasses). - Claim,
position-visibilityis not used because it does not hide a top-layer layer on a page scroll: verified against the layer viewport record. - Claim, the listed tests exist and pass, and the typecheck and lint are clean: verified; 7 of the 9 new popover tests fail on the base.
- Claim, the earlier real-browser run used the previous prop shape: as stated; this review's Chromium and Firefox runs confirm the hide and the focus move at this head.
- Claim, focus moves to the anchor when it is an HTML element that can take focus, else the trigger, and a disabled anchor hands off to the trigger: verified (
usePopover.tsx:693-718; tests; browser runs). - Claim, the docs and release note now say "an HTML element", and the record states the SVG gap: verified.
- Claim, the unused option costs 499 B and 518 B gzip under an exception the stack's spec grants: figures as reported, not re-measured; the exception is not on
main(held above). - Claim, the option will be reworked into built-in behavior: not settled by any record (held above).
- Release note, hidden with no pointer input until the anchor returns, still open,
'stay'default: verified; it no longer floats in Firefox and on a page scroll, while Chromium already left a panel-clipped popover unpainted. - Release note, focus moves to the anchor or the trigger and is not moved back: verified ("does not move it back" test; focus stays on the row in both engines).
- File
.changeset/popover-anchor-out-of-view.md: clear. - File
.changeset/popover-hidden-focus.md: clear. - File
docs/architecture/layer-runtime.md: held (the INV12 clause names a record not onmain). - File
docs/specs/AST-116-popover-anchoring/spec.md: held (record edits wait on the owner). - File
packages/core/src/Layer/useLayer.tsx: the open-while-clipped finding above; two comment notes. - File
packages/core/src/Popover/PopoverAnchorOutOfView.test.tsx: clear; no case opens with the anchor already clipped. - File
packages/core/src/Popover/usePopover.doc.mjs: clear. - File
packages/core/src/Popover/usePopover.tsx: held for the INV10 cost of its static focus import; modality and comment notes. - File
packages/core/src/utils/focusReturn.test.ts: clear. - File
packages/core/src/utils/focusReturn.ts: clear.
| viewportStyles, | ||
| offsetStyle, | ||
| xstyle, | ||
| hidesWithAnchor && !isAnchorInView && styles.anchorOutOfView, |
There was a problem hiding this comment.
Miss: a 'hideWhileOutOfView' popover opened while its anchor is already clipped by a scrolling panel shows for two frames before this style applies. The opening read (:2475-2481) tests the anchor only against the viewport, so the hide waits for IntersectionObserver's first report: Chromium and Firefox read visibility visible, visible, hidden on the first animation frames, Firefox paints the editor outside its panel, and auto-focus puts focus in the editor before the hide moves it to the row. architecture:layer-runtime INV12 says anchor visibility is read before first paint. Suggested fix: for a layer that hides with its anchor, clip the opening read by the anchor's scrolling ancestors (one read at open), and add a test that opens with the anchor already clipped.
6dcfdc9 to
bbff687
Compare
bbff687 to
f42ee7f
Compare
User need
When an anchored popover's anchor scrolls out of a scrolling panel (an app whose content scrolls inside a main region, not the window), the layer runtime holds the popover in place (
spec:AST-059FR5). An inline editor or a filter panel then floats over unrelated content until the anchor returns. Callers whose popover belongs to a row or a header need it to disappear with that row, and come back with it, without losing state.Problem and solution fit
usePopover'sanchorOutOfViewBehavior: 'stay' | 'hideWhileOutOfView'(AST-116 FR7, FR8, DEC-8):'stay'is the default and today's behavior.'hideWhileOutOfView', while the anchor is out of view, the layer is hidden and takes no pointer input. "Out of view" means clipped by the viewport or by any scrolling ancestor, or removed.onHide, and it shows again in place when the anchor returns. The value says "while" becausehide()andonHidemean close.The hide is driven by the runtime's existing anchor-visibility observation (IntersectionObserver, no root), so it reads no layout per scroll frame and moves nothing (
architecture:layer-runtimeINV12, INV21).Current specification
spec:AST-116FR7, FR8, DEC-3, DEC-8 (proposed in #11112; not onmainyet).Public delta and caller burden
anchorOutOfViewBehavior?: 'stay' | 'hideWhileOutOfView'onUsePopoverOptions. Default'stay', unchanged.PopoverPropsis unchanged.utils/focusReturn.tsexportstakesFocusAsIs, the testfocusForLastInputTemporarilyapplied inline; no behavior changes there.useLayerInternaltakes a package-internalhidesWithAnchor. A layer with it set re-observes an anchor that is replaced while open. A layer without it keeps its released render behavior: replacing a trigger still renders the hook once (asserted by the existinguseLayertest).Design and alternatives
visibility: hiddenrather thandisplay: none, so the box and its place in the top layer hold while hidden.position-visibility: anchors-visible.spec:AST-059records that it does not hide a top-layer layer on a page scroll.Evidence
PopoverAnchorOutOfView.test.tsx(stubbed IntersectionObserver):'hideWhileOutOfView': hidden with no pointer events while out of view, still open with noonHide, and visible again on return;'stay'(default) is unchanged;useLayer.test.tsxpasses unchanged.Real browser, Chromium, Firefox and WebKit, run against the earlier
<Popover anchorOutOfView="hide">shape (the same hook path; not re-run since the rename) (script and screenshots): with the anchor scrolled out of its panel the popover readsvisibility: hiddenand stays:popover-open; scrolled back, it is visible in place. WebKit 26.5 (Playwright WebKit on macOS) passes the same checks.Scope
Components: usePopover, Layer (internal)
Testing
pnpm exec vitest run --project ui packages/core/src/Popover packages/core/src/Layer/useLayer.test.tsx: passeduiproject at the top of the stack: see feat(usePopover): tabBehavior lets Tab pass through a popover (spec:AST-116 FR12–FR15, AR4) #11156tsc --noEmit(core), eslint: cleanChanges since the last review
takesFocusAsIs(utils/focusReturn.ts): a tab stop, an element withtabindex, an editable region, or a control the shared focusable selector lists. A box that is only a place to sit, such as a card, is not a candidate.takesFocusAsIssuite infocusReturn.test.ts.usePopoverat its measured cost, and INV10 names the exception; see below.<svg>anchor that can take focus is not a focus target: the JSDoc, the docs and the release note now say "the anchor when it is an HTML element that can take focus", and the record carries anAR1 gap:line for it.First-load size (INV10)
pnpm size:pages --page popover=Popover,Button,Text, this PR's change in gzip bytes against the PR below it (whole stack against the spec head: docs +340, form +363, menu +3,531, table +1,794, popover +3,514):anchorOutOfViewBehavioris optional; the menu and Popover pages grow 518 B and 499 B. Measured in parts:IntersectionObserverthe layer already runs on every open anchored layer.noteFocusWithin,moveFocusLeftBehind, the temporary tab stop), as the review asked. fix(core): one focus return for Popover and DropdownMenu (popover presentation) and Dialog that never strands focus (AST-116 FR17–FR21, AR1) #11121 loads that module on every page; at the top of the stack the focus move's own wiring measures 72 B and 57 B.So the option costs a page that does not use it about 290 to 345 B once the stack has landed. Both figures are over INV10's 0.3 KB allowance and inside the 0.6 KB that AST-116 FR24 allows
anchorOutOfViewBehavior: an engineering owner decided the three composition inputs load withusePopover(AST-116 DEC-9), and INV10 names the exception. A deferred load fits only the focus move, and it would leave focus inside a hidden surface until the code arrived, which AST-116 AR1 rules out.