Skip to content

feat(usePopover): anchorRef names an anchor apart from the trigger (AST-116 FR1–FR3, FR5, FR6) - #11117

Merged
nynexman4464 merged 2 commits into
mainfrom
nynexman4464/feat/popover-anchor
Nov 19, 2026
Merged

nynexman4464 merged 2 commits into
mainfrom
nynexman4464/feat/popover-anchor

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Stack: #11117 → #11121 → #13015

Implements spec:AST-116 FR1–FR3, FR5 and FR6, which is on main. #11121 (focus return) sits on this PR.

User need

A popover often points at something that is not the control that opens it: an inline editor over the table row it edits, one filter panel shared by every column header, a coachmark over a card or chart. Today usePopover anchors only to its trigger, and Popover's anchorRef must be a button (a <button> or an element with role="button") that also becomes the trigger; anything else warns and never anchors. So a popover cannot sit on a cell, a card or a chart region, and a caller who wants one either keeps hidden stand-in buttons in sync with layout or hand-rolls a second overlay.

Problem and solution fit

One usePopover input, anchorRef, names the element the layer sits on; the trigger keeps its own job. The Popover component does not change (AST-116 DEC-8).

  • anchorRef is a ref to any element with a CSS box (AST-116 FR1, FR2). It gets no ARIA and no handler, and it is never a trigger.
  • The ref is read when the popover opens, on each render of the component that calls usePopover, and on each show(). Nothing watches the page for a new element (FR3). A caller that moves an open popover sets anchorRef.current and calls show(). With hasLightDismiss: false the popover moves without a close or remount. With light dismiss on, the press on the other control closes it first and show() opens it again on the new element (the FR9 gap: line below).
  • A composition with anchorRef and no trigger opens through show() and reports dismissals through onHide (FR5).
  • While the ref holds no element in the document, an open popover paints no surface rather than sitting at the page origin (FR6).

There is no function form and no rectangle anchor (AST-116 DEC-1).

Current specification

spec:AST-116 FR1–FR3, FR5, FR6, DEC-1 and DEC-8 (current, on main). This PR adds one sentence to FR6 (a show() with no anchor in the document waits; see Changes since the last review), deletes the FR1 gap line it now meets, and states what is still missing:

FR6 gap: an anchor that leaves the document with no render of the caller's component and no show() leaves the surface shown.

FR9 gap: the browser's light dismiss closes the popover before a show() in the same press runs. With a new anchor element the popover shows again, reports onShow again and runs its initial focus again; with the same element it stays closed and reports onHide.

AR1 gap: when FR6 hides a surface that holds focus, focus is not moved to the trigger or through FR20's chain.

The FR9 line is what real Chromium does at this head: a one-off run of the same rows with light dismiss on (not part of this PR) logged beforetoggle to closed and then to open, a second onShow and no onHide for a press on another row's button, and a close with onHide for a second press on the same row's button.

Public delta and caller burden

  • New optional anchorRef?: React.RefObject<Element | null> on UsePopoverOptions. No new exported type.
  • A shape inside an <svg>, or an <svg> nested directly in another, is not an anchor (it has no CSS box); passing one warns once in development.
  • No default changes. Without anchorRef, the trigger is the anchor exactly as before. PopoverProps is unchanged; Popover's own anchorRef keeps its meaning and its button requirement.

Before (a stand-in button kept over the cell):

<button ref={standInRef} style={{position: 'absolute', ...cellRect}} hidden />
<Popover anchorRef={standInRef} isOpen={isEditing} ... />

After:

const anchorRef = useRef<Element | null>(null);
const editor = usePopover({
  anchorRef,
  dialogLabel: 'Edit value',
  hasLightDismiss: false,
});

// in a row's edit button:
onClick={event => {
  anchorRef.current = event.currentTarget;
  editor.show();
}}
// render with editor.render(<Editor />)

Design and alternatives

  • The ref is checked on every commit and on each show(). No observer watches the document for a new element.
  • The layer still follows its anchor only through CSS anchor positioning (architecture:layer-runtime INV21).
  • Rejected (AST-116 DEC-1): a function that returns the anchor, a name without Ref, and widening Popover's anchorRef to non-buttons. Rejected (DEC-8): a position-only anchor on the Popover component.

Evidence

PopoverAnchor.test.tsx (all through usePopover), 19 tests:

  • a non-button anchor carries the anchor name while the trigger keeps aria-expanded, aria-haspopup and aria-controls; the anchor gets no ARIA, and a press on it does not open the popover;
  • falling back to the trigger when anchorRef is dropped;
  • a trigger-less popover opened by show() and its onHide on dismissal;
  • a development warning for a shape or a nested <svg> inside an <svg>, and none for an outer <svg> or one inside <foreignObject>;
  • a table cell and an <svg> element as anchors;
  • the ref set to another row's element and show() called while open (light dismiss off): the anchor name moves, the surface node is the same, onHide is not called, and focus stays on the field it was in;
  • an element replaced outside React is not followed until the next render (nothing watches the page);
  • a show() while the ref is empty waits, and opens on the next show() once the ref holds an element, and on the next render when React attaches the ref;
  • no surface while an open popover's anchor is gone, and while the ref holds an element that left the document; a show() on such a ref waits;
  • an open popover that unmounts takes its anchor name off the caller's element (fails without the unmount cleanup);
  • under StrictMode, where each effect runs, cleans up and runs again, the anchor is bound again and the popover opens on it (fails without the reset in the cleanup); a popover that opens on mount stays anchored and shown there;
  • a show() after the bound element left the document, or after the ref was emptied, with no render between, waits (both fail when the layer drops a named anchor a microtask late);
  • a trigger that mounts after the anchor is bound does not take the anchor.

Real browser, PopoverAnchor.interaction.browser.spec.ts on the new Core/Popover Anchor Ref story, 2 of 2 in Chromium and in WebKit:

  • the popover sits beside the cell the ref holds; after the ref is set to another row's cell and show() runs, the same surface node sits beside that cell, still open, with the value typed into it, one show and no hide;
  • with the anchor's cell removed the surface is hidden and not closed; after the cell is restored and the caller names it and calls show(), the surface is beside it again.

Not covered at this head: Firefox, and the same-press move with light dismiss on (FR9, which the PR above this one implements).

Scope

Components: usePopover

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm exec vitest run --project ui packages/core/src/Popover/PopoverAnchor.test.tsx: 19 passed
  • pnpm exec vitest run --project ui packages/core/src/Popover packages/core/src/Layer: 858 passed
  • pnpm test:interaction PopoverAnchor.interaction.browser.spec.ts --project chromium, and the same spec in WebKit: 2 passed each
  • tsc --noEmit (core): clean
  • eslint on the changed files: clean
  • pnpm check:knowledge: passes
  • Local run of the CI jobs lint, typecheck and the four test-ui shards: pass

Changes since the last review

  • A show() after the ref was emptied (its last element still in the document, no render between) opened the popover on that element. The layer now drops a named anchor at once, where it used to wait a microtask, so that show() waits. The layer's separate check for a disconnected element is gone: the same path covers it.
  • spec:AST-116 FR6 gains one sentence: a show() while the ref holds no element in the document does not open the popover; it opens, and reports onShow, when a later read finds one. The code, the docs and the release note already said so; the record did not. This sentence needs an engineering owner's approval at this head.
  • Two more tests: the emptied ref, and a popover that opens on mount under StrictMode.
  • Two source comments reworded as the last review asked.
  • Rebased onto main.

Writing rubric results

The record changes are one requirement sentence, gap lines and one pointer: FR6 gains the sentence about a show() that waits, in the present tense; the FR1 gap: line is removed, FR6 gap: and AR1 gap: are added and FR9 gap: is reworded in spec:AST-116, and component:Popover drops one "FR1 gap there" pointer and gains one "FR6 gap there" pointer.

  • R1 narration: none in the changed lines.
  • R2 research in the record: none.
  • R3 evidence naming a change: none.
  • R4 rejected alternatives: none added.
  • R5 pull request or issue references: none.
  • R6 ruled open questions still listing options: none.
  • R7 project status: only the gap lines above, each stating an observable mismatch.

First-load size (INV10)

pnpm size:pages --page popover=Popover,Button,Text, this PR's change in gzip bytes against main:

docs form menu table popover
+77 +80 +271 +52 +247

anchorRef is optional; the menu and Popover pages, which do not set it, grow 271 B and 247 B. That is inside the 0.3 KB (307 B) that architecture:component-import-boundaries INV10 allows an unused optional feature, so no exception is needed. The development warning for a shape is behind the production guard and is not in these bundles.

@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 19, 2026 8:33pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 10, 2026
@astracat-bot

astracat-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 19, 2026, 8:52 PM UTC

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about the new anchor input: spec:AST-113 (FR1–FR3, FR5, FR6, FR19, DEC-1) is still a draft and not on main, so no current spec settles anchor on Popover and usePopover, the exported PopoverAnchor type, the trigger-less controlled Popover, or which element sets the default width. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (you may do so yourself as an engineering owner), or by promoting AST-113 to current.

These need fixes either way:

  • A trigger-less popover whose anchor arrives late opens hidden, reports onOpenChange(true), and is light-dismissed by the first outside press before it ever shows (usePopover.tsx:679-680); the late-anchor test passes only because it sets hasLightDismiss={false}.
  • usePopover builds its own anchor-readiness path (isAnchorMissing, the unanchored style and a raw document MutationObserver, usePopover.tsx:596 and :646-665) beside useLayer's existing wait for a usable anchor and the shared observeMutations utility, and extending useLayer's wait would also fix the bullet above.
  • With a separate anchor and no width, the popover's minimum width follows the anchor (a 960 px row gives a 960 px popover), while component:Popover ORD2 says it follows the trigger, so keep the trigger as the width reference or have the owner amend ORD2 and document it on anchor.

A real-browser test of the late-anchor and width cases would close the gap the jsdom suite leaves.

[Automated review]

Comment thread packages/core/src/Popover/Popover.tsx Resolved
Comment thread packages/core/src/Popover/Popover.tsx Resolved

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about the new anchor input: spec:AST-113 (FR1–FR3, FR5, FR6, FR23, DEC-1) is still a draft and not on main, so no current spec settles anchor on Popover and usePopover, the exported PopoverAnchor type, the trigger-less controlled Popover, or which element sets the default width. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (you may do so yourself as an engineering owner), or by promoting AST-113 to current.

These need fixes either way:

  • A trigger-less popover whose anchor arrives late opens hidden, reports onOpenChange(true), and is light-dismissed by the first outside press before it ever shows (usePopover.tsx:679-680); the late-anchor test passes only because it sets hasLightDismiss={false}.
  • usePopover builds its own anchor-readiness path (isAnchorMissing, the unanchored style and a raw document MutationObserver, usePopover.tsx:596 and :646-665) beside useLayer's existing wait for a usable anchor and the shared observeMutations utility, and extending useLayer's wait would also fix the bullet above.
  • With a separate anchor and no width, the popover's minimum width follows the anchor (a 960 px row gives a 960 px popover), while component:Popover ORD2 says it follows the trigger, so keep the trigger as the width reference or have the owner amend ORD2 and document it on anchor.

The base branch has since renumbered AST-113, so the description's FR18/FR19 and the test header's FR19 now point at focus-return claims; the compatibility claims are FR22 and FR23.

Automated review (maintainer link)

Comment thread packages/core/src/Popover/Popover.tsx Resolved
@nynexman4464
nynexman4464 force-pushed the nynexman4464/docs/ast-113-popover-anchoring branch from e6927de to e4cff57 Compare November 11, 2026 15:43
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor branch from b905360 to 199db1d Compare November 11, 2026 15:43
@nynexman4464 nynexman4464 changed the title feat(Popover): an anchor apart from the trigger (AST-113 FR1–FR3, FR5, FR6) feat(Popover): an anchor apart from the trigger (AST-116 FR1–FR3, FR5, FR6) Nov 11, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about the new anchor input: spec:AST-116 (FR1–FR3, FR5, FR6, FR23, DEC-1) is still a draft and not on main, so no current spec settles anchor on Popover and usePopover, its name, the exported PopoverAnchor type, the trigger-less controlled Popover, or which element sets the default width. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request (you may do so yourself as an engineering owner), or by promoting AST-116 to current.

These need fixes either way:

  • A trigger-less popover whose anchor arrives late opens hidden, reports onOpenChange(true), and is light-dismissed by the first outside press before it ever shows (usePopover.tsx:679-680); the late-anchor test passes only because it sets hasLightDismiss={false}.
  • usePopover builds its own anchor-readiness path (isAnchorMissing, the unanchored style and a raw document MutationObserver, usePopover.tsx:596 and :646-665) beside useLayer's existing wait for a usable anchor and the shared observeMutations utility, and extending useLayer's wait would also fix the bullet above.
  • With a separate anchor and no width, the popover's minimum width follows the anchor (a 960 px row gives a 960 px popover), while component:Popover ORD2 says it follows the trigger, so keep the trigger as the width reference or have the owner amend ORD2 and document it on anchor.
  • Miss: an SVG anchor such as a chart bar paints the open popover at the page origin, because an SVG shape has no CSS box, while the changeset and docs promise "a chart region", so narrow the type and the wording (or hide and warn for such an anchor) and add an SVG case to PopoverAnchor.test.tsx.

The test header and the description still cite FR19 for the anchorRef compatibility claim, which is FR23 in AST-116.

Automated review (maintainer link)

@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor branch from 199db1d to 4a33324 Compare November 16, 2026 22:36
@nynexman4464 nynexman4464 changed the title feat(Popover): an anchor apart from the trigger (AST-116 FR1–FR3, FR5, FR6) feat(usePopover): an anchor apart from the trigger (AST-116 FR1–FR3, FR5, FR6) Nov 16, 2026

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about the new anchor input: spec:AST-116 (FR1–FR3, FR5, FR6, DEC-1, DEC-7, DEC-8) is still a draft and not on main, so no current spec settles anchor on usePopover, the exported PopoverAnchor type, the trigger-less composition opened through show() or the hidden surface while the anchor resolves to nothing, and that decision also has to amend component:Popover's "Trigger binding" output and "Side effects and lifetime" line, which say the trigger carries the anchor name. An engineering owner records it by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), or by promoting AST-116 to current.

These need fixes either way:

  • Newly live check: anchorOptionRef.current = anchor writes a ref during render (usePopover.tsx:592), so use useCommittedRef(anchor), which the base branch now has.
  • A trigger-less popover opened before its anchor exists fires onShow, paints nothing and is light-dismissed by the first outside press, and with light dismiss off it appears on the wrong side with no initial focus (usePopover.tsx:659-660); the late-anchor test passes only because it turns light dismiss off.
  • usePopover adds its own anchor-readiness state (isAnchorMissing, styles.unanchored) beside useLayer's existing wait for a usable anchor, so extend that wait to a missing anchor instead, which also fixes the bullet above.
  • An SVG anchor such as a chart bar paints the open popover at the viewport corner while the type admits any Element and the changeset promises "a chart region", so narrow the type and the wording (or treat a boxless anchor as unresolved) and add an SVG test.
  • The description's Testing section says PopoverAnchor.test.tsx passes 10 tests, but the file has 7 cases and 7 pass.

Please also put the first-load deltas in the description (measured here: Popover page +292 B gzip, menu page +257 B, the other reference pages unchanged, all within the limit) and rebase onto the base branch, which this head conflicts with in usePopover.tsx.

Claims and files checked

Review mode: full; reason: rebase

Claims:

  • usePopover takes an anchor that may be any element: verified for HTML elements (test, Chromium); false for SVG shapes (finding).
  • A function anchor is read on open and when a different function is passed, so an open popover moves between rows without closing: verified (row-switch test).
  • Nothing watches the page: verified (replaced-element test; no observer in the diff).
  • The trigger keeps its toggle and ARIA and the anchor gets neither: verified (test and Chromium probe).
  • A composition with an anchor and no trigger opens through show() and reports dismissals through onHide: verified (trigger-less test).
  • An unresolved anchor shows no surface: verified for a missing element, but the popover is already open and dismissable while hidden (finding).
  • The Popover component is unchanged and no default changes: verified (Popover is not in the diff; the Popover, DropdownMenu and Layer suites pass, 1,133 tests).
  • Today anchorRef must be a button and anything else warns and never anchors: verified in the Popover source.
  • The new test file passes 10 tests: false, it has 7 and 7 pass.
  • The whole core test project passes: not re-run in full; a 48-file subset passes.
  • Typecheck is clean and ESLint reports nothing new: verified.
  • Real-browser checks ran on an earlier shape and were not re-run: as stated; this review's Chromium run covers the current shape.

Files:

  • .changeset/popover-anchor.md: "a chart region" overclaims (SVG finding).
  • packages/core/src/Popover/PopoverAnchor.test.tsx: the late-anchor case runs with light dismiss off, and no case renders an SVG anchor.
  • packages/core/src/Popover/index.ts: clear, pending the API decision.
  • packages/core/src/Popover/popoverAnchor.ts: the type admits SVG elements (SVG finding).
  • packages/core/src/Popover/usePopover.doc.mjs: clear, pending the API decision.
  • packages/core/src/Popover/usePopover.tsx: render-time ref write, open before the anchor resolves, second readiness path.

Automated review (maintainer link)

Comment thread .changeset/popover-anchor.md Resolved
@nynexman4464
nynexman4464 force-pushed the nynexman4464/docs/ast-113-popover-anchoring branch from 0743846 to ea2da64 Compare November 18, 2026 01:47
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor branch from 4a33324 to 1c3386f Compare November 18, 2026 03:56

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about the new anchor input: spec:AST-116 (FR1–FR3, FR5, FR6, FR23, DEC-1, DEC-7, DEC-8) is not on main, and the only owner approval on its spec pull request names an earlier head, so no current spec yet settles anchor on usePopover, the exported PopoverAnchor type, the trigger-less composition opened through show() or the hidden surface while the anchor resolves to nothing. That decision also replaces component:Popover's current Trigger binding and side-effect lines, which make the attached trigger the anchor. An engineering owner records it by merging the spec pull request or by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner.

These need fixes either way:

  • A trigger-less popover opened before its anchor exists fires onShow, paints nothing and is light-dismissed by the click that mounts its anchor, and with light dismiss off it appears without moving focus into it (usePopover.tsx:733-734); the late-anchor test passes only because its helper turns light dismiss off.
  • usePopover adds its own anchor-readiness state (isAnchorMissing, styles.unanchored) beside useLayer's existing wait for a usable anchor, so extend that wait to a declared anchor that has not resolved instead, which also fixes the bullet above.
  • An SVG shape such as a chart bar paints the open popover at the viewport corner, and AST-116 FR2 says it is not an anchor, yet the changeset, usePopover.doc.mjs and both JSDoc blocks promise "any element" and "a chart region", so say an element with a CSS box (an HTML element or an <svg> element) instead.
  • The description says PopoverAnchor.test.tsx has 7 cases, but it runs 9, and the table-cell and <svg> cases are missing from the list.
Claims and files checked

Review mode: full; reason: rebase

Claims:

  • usePopover takes an anchor, the element the popover sits on apart from its opener: verified (new option and Chromium check on a table cell).
  • An anchor may be any element, such as a card, a table cell or a chart region: false for SVG shapes (finding); verified for HTML elements and an <svg> element.
  • A ref is read on open and on each render, a function on open and when a different function is passed, and nothing watches the page: verified (layout effect, the replaced-element test, no observer in the diff).
  • A new function moves an open popover between rows without closing it: verified (row-switch test and Chromium).
  • The trigger keeps its toggle and ARIA and the anchor gets neither: verified (test, Chromium probe; a second trigger press still closes it).
  • A composition with an anchor and no trigger opens through show() and reports dismissals through onHide: verified (trigger-less test), but a late anchor loses it (finding).
  • An unresolved anchor paints no surface rather than sitting at the page origin: verified for the paint (Chromium), with the dismissal and focus gaps in the findings.
  • There is no rectangle anchor: verified (type).
  • The Popover component is unchanged, no default changes, and anchorRef keeps its button requirement: verified (no Popover change in the diff, API delta has no Popover rows, suites pass).
  • Today a non-button anchorRef warns and never anchors: verified in the Popover source.
  • The layer follows its anchor through CSS anchor positioning only: verified (no script positioning).
  • The spec record is current and approved: not established; it is not on main and its approval names an earlier head of the spec pull request.
  • This change deletes the FR1 gap line it meets: verified (record diff).
  • The new test file has 7 cases: false, it runs 9 (finding).
  • The whole core test project passes: not re-run in full; the Popover, DropdownMenu and Layer suites pass.
  • Typecheck is clean and ESLint reports nothing new: verified (core build typecheck, ESLint on the changed files).
  • Real-browser checks ran on an earlier shape and were not re-run: as stated; this review's Chromium run covers the current shape.
  • First-load deltas (docs +0, form +0, menu +238, table +0 B gzip): verified within a byte (menu +237 B; a Popover page +235 B).
  • No internal context in public text: verified.

Files:

  • .changeset/popover-anchor.md: "a chart region" overclaims (SVG finding).
  • docs/specs/AST-116-popover-anchoring/spec.md: removes the FR1 gap line; the record still needs owner approval.
  • docs/specs/components/Popover/Popover.spec.md: drops the FR1 gap mention; clear, pending the same approval.
  • packages/core/src/Popover/PopoverAnchor.test.tsx: the trigger-less cases run with light dismiss off, and no case renders an SVG shape.
  • packages/core/src/Popover/index.ts: clear, pending the API decision.
  • packages/core/src/Popover/popoverAnchor.ts: the type and its JSDoc admit SVG shapes (SVG finding).
  • packages/core/src/Popover/usePopover.doc.mjs: "any element" overclaims (SVG finding).
  • packages/core/src/Popover/usePopover.tsx: opens before the anchor resolves, second readiness path, "any element" in the JSDoc.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about the new anchor input: spec:AST-116 (FR1–FR3, FR5, FR6, FR23, DEC-1, DEC-7, DEC-8) is not on main and its only owner approval names an earlier head of the spec pull request, so no current spec settles anchor on usePopover, the exported PopoverAnchor type, the trigger-less composition or the hidden surface; approving them also replaces component:Popover's current Trigger binding and side-effect lines. That decision also has to settle two departures at this head (the code re-reads an unchanged function anchor on every render until it resolves, which FR3 and DEC-7 rule out, and this pull request rewrites the record's FR3/FR6 verification row from a real-browser interaction spec to an evidence gap), and an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request (the author may, as an engineering owner) or by amending and merging the spec pull request.

These need fixes either way:

  • anchor adds 329 B gzip of first-load JavaScript to the menu reference page and 339 B to a Popover page that never set it, over the 307 B that INV10 allows, so move the anchor code behind its own import or a deferred load (an exception would need an owner to amend INV10).
  • The changeset and usePopover.doc.mjs say a show() before the anchor exists "waits until it does", but the wait ends only when the component that calls usePopover renders again, so a target mounted by another component never opens the popover; say that instead, in the JSDoc too.

Fixed since the last review: the late-anchor popover lost to light dismiss, the second anchor-readiness path, the SVG-shape wording and the test count.

Claims and files checked

Review mode: full; reason: history

Claims:

  • usePopover takes an anchor, the element the popover sits on apart from its opener: verified (new option; Chromium check on a table cell).
  • An anchor is an element with a CSS box, an HTML element or an <svg> element, not a shape inside one: verified (docs, changeset and both JSDoc blocks; table-cell and <svg> tests).
  • A show() before the anchor exists waits until it does: verified only when the hook's own component renders again; false when another component mounts the anchor (finding).
  • A ref is read on open and on each render, a function on open and when a different one is passed, and nothing watches the page: verified, plus a function that returned nothing is re-read on every render until it resolves, as the description's change list says (held for the owner decision).
  • A new function moves an open popover between rows without closing it: verified (row test).
  • The trigger keeps its toggle and ARIA, and the anchor gets neither: verified (test; Chromium probe).
  • A composition with an anchor and no trigger opens through show() and reports dismissals through onHide: verified (trigger-less test).
  • An open popover whose anchor resolves to nothing paints no surface: verified for a ref anchor (test; Chromium).
  • A named anchor whose element left the page counts as no anchor: verified (layer runtime's show).
  • There is no rectangle anchor: verified (type).
  • The Popover component is unchanged, no default changes, and anchorRef keeps its button requirement: verified (no Popover change; API delta lists three added rows only).
  • Today a non-button anchorRef warns and never anchors: verified in the Popover source.
  • The layer follows its anchor through CSS anchor positioning only: verified (no script positioning).
  • The spec record is current and approved: not established; it is not on main and its approval names an earlier spec head.
  • The change deletes the FR1 gap line it meets: verified (record diff).
  • The new tests cover the listed cases: verified, each listed case matches a test, and the table-cell and <svg> case is extra.
  • The whole core test project passes: verified (886 files, 23,770 tests).
  • Typecheck is clean and ESLint reports nothing new: verified (core build typecheck; ESLint on the changed files).
  • Real-browser checks ran on an earlier shape and were not re-run: as stated; this review's Chromium run covers the current shape.
  • First-load deltas (docs +76, form +79, menu +328, table +76, Popover page +339 B gzip), over the limit on two pages: verified within two bytes (menu +329, table +78); the overrun is a finding.
  • No internal context in public text: verified.

Files:

  • .changeset/popover-anchor.md: "waits until it does" overclaims (finding).
  • docs/specs/AST-116-popover-anchoring/spec.md: removes the FR1 gap line and rewrites the FR3/FR6 verification row as an evidence gap; held for the owner decision.
  • docs/specs/components/Popover/Popover.spec.md: drops the FR1 gap mention; clear, pending the same decision.
  • packages/core/src/Layer/useLayer.tsx: the anchor wait; unchanged for callers without anchor; part of the INV10 growth.
  • packages/core/src/Popover/PopoverAnchor.test.tsx: clear; the late-anchor case mounts its target in the hook's own component.
  • packages/core/src/Popover/index.ts: clear, pending the API decision.
  • packages/core/src/Popover/popoverAnchor.ts: clear, pending the API decision.
  • packages/core/src/Popover/usePopover.doc.mjs: "waits until it does" overclaims (finding).
  • packages/core/src/Popover/usePopover.tsx: INV10 growth (finding); function re-read held for the owner decision; one narrating comment (non-blocking).

Automated review (maintainer link)

Comment thread .changeset/popover-anchor.md Resolved

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approval waits on an engineering owner's decision about the new anchorRef option on usePopover: its spec, AST-116, is not on main, and its anchorRef text has no spec approval at the current head of the spec pull request (#11112) or at this head. That decision covers the ref's read rule (on open, on each render and on each show()), the trigger-less and waiting show(), the hidden surface while the anchor is gone, the gap lines this head adds or rewords, and replacing Popover's current rule that the attached trigger is the anchor; an engineering owner records it by commenting /approve-spec <full head SHA> on this pull request (the author may, as an engineering owner) or by approving and merging the spec pull request at its head. No blocking defect remains: the first-load cost is now within the 0.3 KB allowance (+297 B gzip on the menu page, +296 B on a Popover page), and one non-blocking comment note is inline.

Claims and files checked

Review mode: full; reason: spec-record

Claims:

  • The input is a ref-only anchorRef, matching the revised spec: verified (option type and docs).
  • Today usePopover anchors only to its trigger, and Popover's own anchorRef must be a button: verified (base source and Popover's current spec).
  • The Popover component does not change: verified (not in the diff).
  • Any element with a CSS box works, including a table cell and an <svg>; a shape or a nested <svg> warns once in development: verified (tests).
  • The anchor gets no ARIA and no handler and is never a trigger, and the trigger keeps its toggle and ARIA: verified (test; in Chromium a second press on the trigger closes the popover and a press on the anchor is an outside press).
  • The ref is read on open, on each render and on each show(), and nothing watches the page: verified (code; replaced-element test).
  • With light dismiss off, setting the ref and calling show() moves an open popover without a close or remount: verified (test; Chromium frames show the same surface with its value, one show and no hide).
  • With light dismiss on, the press on another row closes the popover first and show() opens it again on the new element: verified from the code (the dismissed anchor differs from the new one); not run in a browser.
  • A show() while the ref holds no element waits and opens on the next read that finds one: verified (tests).
  • A composition with no trigger opens through show() and reports onHide on dismissal: verified (test).
  • An open popover whose anchor is gone shows no surface: verified (tests; in Chromium it is hidden, not closed).
  • No new exported type and no default change: verified (API comparison: one added option).
  • The layer follows its anchor only through CSS anchor positioning: verified.
  • The 17 tests in the new file pass: verified.
  • Three tests fail without the unmount cleanup, the StrictMode reset or the connected check: not rechecked by mutation.
  • The real-browser spec passes in Chromium and WebKit: not run; the Chromium frames here reproduce both of its scenarios.
  • The Popover and Layer suites pass, the typecheck and ESLint are clean, and the knowledge check passes: verified (Popover, Layer, DropdownMenu and ContextMenu suites; source typecheck through the core build; ESLint; knowledge check).
  • First-load deltas of docs +76, form +79, menu +297, table +76 and Popover page +296 B gzip: verified within 1 B (table +77), all within the 307 B allowance.
  • The record edits are gap lines and one pointer, each naming its requirement and the mismatch: verified.

Files:

  • .changeset/popover-anchor.md: clear.
  • apps/storybook/stories/PopoverAnchorRef.stories.tsx: clear.
  • docs/specs/AST-116-popover-anchoring/spec.md: gap lines; clear, pending the owner decision.
  • docs/specs/components/Popover/Popover.spec.md: one pointer; clear, pending the owner decision.
  • packages/core/src/Layer/useLayer.tsx: clear; the new wait applies only to a caller that names an anchor.
  • packages/core/src/Popover/PopoverAnchor.test.tsx: clear.
  • packages/core/src/Popover/__tests__/PopoverAnchor.interaction.browser.spec.ts: clear (not run here).
  • packages/core/src/Popover/popoverAnchor.ts: clear; one open comment-wording thread.
  • packages/core/src/Popover/usePopover.doc.mjs: clear.
  • packages/core/src/Popover/usePopover.tsx: one non-blocking note on the Effect comment.

Automated review (maintainer link)

@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor branch from bbff687 to f42ee7f Compare November 19, 2026 03:08
@nynexman4464
nynexman4464 changed the base branch from nynexman4464/docs/ast-113-popover-anchoring to main November 19, 2026 03:08
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 19, 2026
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 4fb4c8b

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
LayerProvider 4.4 kB (0) · 20 B CSS (0) — ✓ · ✓ · ✗
lab/TransferListSelector 146.9 kB (+294 B) · 1.4 kB CSS (0) — — · — · —
Typeahead 90.8 kB (+266 B) · 13.9 kB CSS (+19 B) — — · — · —
126 more components
Component Size LoC Visual · A11y · RTL
ChatComposer 86.9 kB (+274 B) · 13.3 kB CSS (+9 B) — — · — · —
BaseTypeahead 80.7 kB (+273 B) · 12.1 kB CSS (+9 B) — — · — · —
ComplexSelector 79.8 kB (+265 B) · 13.0 kB CSS (+9 B) — — · — · —
BreadcrumbItem 99.5 kB (+253 B) · 14.0 kB CSS (+7 B) — — · — · —
lab/Comments 384.2 kB (+257 B) · 2.5 kB CSS (0) — — · — · —
Selector 116.4 kB (+246 B) · 19.2 kB CSS (+9 B) — — · — · —
TopNavHeading 84.5 kB (+242 B) · 12.4 kB CSS (+10 B) — — · — · —
PowerSearch 314.2 kB (+250 B) · 26.8 kB CSS (0) — — · — · —
TopNavMenu 84.0 kB (+237 B) · 12.4 kB CSS (+9 B) — — · — · —
Popover · Storybook 101.3 kB (+231 B) · 15.5 kB CSS (+9 B) 1,641 (+86) ✓ · ✓ · ✓
richtext/RichTextEditorToolbar 311.2 kB (+237 B) · 454 B CSS (0) — — · — · —
SideNavItem 79.2 kB (+223 B) · 12.3 kB CSS (+10 B) — — · — · —
Pagination 149.3 kB (+220 B) · 19.6 kB CSS (+12 B) — — · — · —
DropdownMenu 110.2 kB (+225 B) · 19.8 kB CSS (+6 B) — — · — · —
ChatComposerInput 84.6 kB (+222 B) · 12.5 kB CSS (+8 B) — — · — · —
ChatComposerTokenElement 84.6 kB (+222 B) · 12.5 kB CSS (+8 B) — — · — · —
SideNavHeading 84.9 kB (+220 B) · 12.5 kB CSS (+9 B) — — · — · —
DateTimeInput 227.9 kB (+228 B) · 20.1 kB CSS (0) — — · — · —
MultiSelector 104.9 kB (+217 B) · 18.4 kB CSS (+11 B) — — · — · —
DateRangeInput 101.9 kB (+227 B) · 13.7 kB CSS (0) — — · — · —
MoreMenu 110.5 kB (+221 B) · 19.8 kB CSS (+6 B) — — · — · —
lab/ChatEmojiPicker 123.9 kB (+227 B) · 773 B CSS (0) — — · — · —
Tokenizer 109.0 kB (+226 B) · 21.4 kB CSS (0) — — · — · —
lab/ChatReactionBar 125.1 kB (+219 B) · 1.1 kB CSS (0) — — · — · —
TopNavMegaMenu 78.6 kB (+205 B) · 13.0 kB CSS (+9 B) — — · — · —
lab/MediaPlaybackRate 224.9 kB (+209 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaSeekButton 224.9 kB (+209 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaTime 224.9 kB (+209 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaVolume 224.9 kB (+209 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaPlayButton 224.9 kB (+208 B) · 1.5 kB CSS (0) — — · — · —
DateInput 204.3 kB (+207 B) · 18.4 kB CSS (0) — — · — · —
lab/CommentThread 377.1 kB (+207 B) · 2.4 kB CSS (0) — — · — · —
lab/MediaCaptionsButton 224.9 kB (+207 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaTimeSlider 224.9 kB (+207 B) · 1.5 kB CSS (0) — — · — · —
lab/MediaFullscreenButton 224.9 kB (+206 B) · 1.5 kB CSS (0) — — · — · —
lab/CommentComposer 182.3 kB (+200 B) · 1.9 kB CSS (0) — — · — · —
TabMenu 81.1 kB (+198 B) · 12.3 kB CSS (0) — — · — · —
lab/VideoPlayer 233.1 kB (+193 B) · 2.0 kB CSS (0) — — · — · —
lab/AudioPlayer 234.7 kB (+122 B) · 1.8 kB CSS (0) — — · — · —
AvatarGroupOverflow 52.6 kB (+61 B) · 6.0 kB CSS (0) — — · — · —
Lightbox 150.7 kB (+60 B) · 12.3 kB CSS (0) — — · — · —
lab/SelectableCardGroup 70.3 kB (+57 B) · 162 B CSS (0) — — · — · —
DropdownMenuSubMenu 80.1 kB (+56 B) · 11.0 kB CSS (0) — — · — · —
FieldLabel 56.5 kB (+54 B) · 6.1 kB CSS (0) — — · — · —
lab/DiffViewer 95.4 kB (+54 B) · 2.1 kB CSS (0) — — · — · —
Toolbar 47.9 kB (+48 B) · 8.6 kB CSS (0) — — · — · —
lab/DialogHeroHeader 91.6 kB (+48 B) · 372 B CSS (0) — — · — · —
Slider 115.8 kB (+47 B) · 9.2 kB CSS (0) — — · — · —
Toast 106.7 kB (+47 B) · 11.4 kB CSS (0) — — · — · —
MobileNav 78.8 kB (+46 B) · 11.8 kB CSS (0) — — · — · —
AppShell 100.4 kB (+45 B) · 14.9 kB CSS (0) — — · — · —
Thumbnail 71.6 kB (+45 B) · 12.7 kB CSS (0) — — · — · —
TopNav 80.6 kB (+44 B) · 12.1 kB CSS (0) — — · — · —
richtext/RichTextEditor 309.8 kB (+44 B) · 2.7 kB CSS (0) — — · — · —
HoverCard 30.9 kB (+43 B) · 4.8 kB CSS (0) — — · — · —
lab/ListInput 96.2 kB (+43 B) · 922 B CSS (0) — — · — · —
Stepper 68.9 kB (+41 B) · 11.3 kB CSS (0) — — · — · —
TabList 48.2 kB (+41 B) · 6.8 kB CSS (0) — — · — · —
TextArea 93.6 kB (+38 B) · 9.7 kB CSS (0) — — · — · —
TimeInput 178.8 kB (+38 B) · 17.3 kB CSS (0) — — · — · —
DialogHeader 70.4 kB (+37 B) · 12.8 kB CSS (0) — — · — · —
DrawerHeader 70.6 kB (+37 B) · 14.3 kB CSS (0) — — · — · —
ToggleButton 94.5 kB (+37 B) · 11.3 kB CSS (0) — — · — · —
CheckboxList 74.4 kB (+36 B) · 8.1 kB CSS (0) — — · — · —
IconButton 67.2 kB (+36 B) · 11.1 kB CSS (0) — — · — · —
SegmentedControl 103.0 kB (+36 B) · 7.2 kB CSS (0) — — · — · —
StatusDot 34.5 kB (+36 B) · 5.7 kB CSS (0) — — · — · —
lab/TabBarMoreList 103.6 kB (+36 B) · 1.8 kB CSS (0) — — · — · —
richtext/RichTextView 287.0 kB (+36 B) · 2.4 kB CSS (0) — — · — · —
ChatLayoutScrollButton 67.8 kB (+35 B) · 11.3 kB CSS (0) — — · — · —
NumberInput 104.9 kB (+35 B) · 12.6 kB CSS (0) — — · — · —
lab/EmojiPicker 119.6 kB (+34 B) · 751 B CSS (0) — — · — · —
Calendar 78.4 kB (+33 B) · 11.8 kB CSS (0) — — · — · —
ChatDictationButton 67.8 kB (+33 B) · 11.2 kB CSS (0) — — · — · —
RadioListItem 77.6 kB (+33 B) · 11.1 kB CSS (0) — — · — · —
Switch 110.6 kB (+33 B) · 10.4 kB CSS (0) — — · — · —
MobileNavToggle 67.5 kB (+32 B) · 11.1 kB CSS (0) — — · — · —
lab/TourStep 96.1 kB (+32 B) · 691 B CSS (0) — — · — · —
Button 67.2 kB (+31 B) · 11.1 kB CSS (0) — — · — · —
RadioList 62.1 kB (+31 B) · 7.6 kB CSS (0) — — · — · —
Avatar 46.6 kB (+30 B) · 6.0 kB CSS (0) — — · — · —
Field 60.6 kB (+30 B) · 7.6 kB CSS (0) — — · — · —
InfoTip 51.4 kB (+29 B) · 5.7 kB CSS (0) — — · — · —
SideNavCollapseButton 68.1 kB (+29 B) · 11.2 kB CSS (0) — — · — · —
lab/CommentPin 61.4 kB (+29 B) · 1.2 kB CSS (0) — — · — · —
ChatLayout 90.8 kB (+28 B) · 11.7 kB CSS (0) — — · — · —
Carousel 77.3 kB (+27 B) · 12.1 kB CSS (0) — — · — · —
ChatSendButton 67.6 kB (+27 B) · 11.1 kB CSS (0) — — · — · —
CodeBlock 83.2 kB (+27 B) · 12.9 kB CSS (0) — — · — · —
TableSelectionToolbar 77.6 kB (+27 B) · 14.5 kB CSS (0) — — · — · —
CheckboxListItem 81.5 kB (+24 B) · 12.5 kB CSS (0) — — · — · —
InputGroup 62.2 kB (+24 B) · 8.2 kB CSS (0) — — · — · —
TextInput 99.9 kB (+24 B) · 12.3 kB CSS (0) — — · — · —
Tooltip 32.8 kB (+23 B) · 4.8 kB CSS (0) — — · — · —
CheckboxInput 70.6 kB (+22 B) · 10.6 kB CSS (0) — — · — · —
FileInput 76.2 kB (+22 B) · 12.1 kB CSS (0) — — · — · —
lab/TransferList 137.8 kB (+21 B) · 1.2 kB CSS (0) — — · — · —
ListItem 80.6 kB (+20 B) · 12.5 kB CSS (0) — — · — · —
Link 57.6 kB (+18 B) · 7.4 kB CSS (0) — — · — · —
AlertDialog 130.9 kB (+17 B) · 16.2 kB CSS (0) — — · — · —
AvatarGroup 49.4 kB (+17 B) · 6.1 kB CSS (0) — — · — · —
charts/Chart 244.3 kB (+16 B) · 516 B CSS (0) — — · — · —
Banner 69.3 kB (+16 B) · 11.6 kB CSS (0) — — · — · —
charts/ChartTooltip 220.9 kB (+15 B) · 451 B CSS (0) — — · — · —
SideNav 123.6 kB (+13 B) · 12.5 kB CSS (0) — — · — · —
Table 123.6 kB (+12 B) · 21.1 kB CSS (0) — — · — · —
ContextMenu 104.6 kB (+8 B) · 19.6 kB CSS (0) — — · — · —
lab/Schedule 117.0 kB (+8 B) · 3.9 kB CSS (0) — — · — · —
TableHeaderCell 105.7 kB (+7 B) · 20.0 kB CSS (0) — — · — · —
TableCell 105.8 kB (+6 B) · 20.1 kB CSS (0) — — · — · —
Markdown 207.8 kB (+5 B) · 23.4 kB CSS (0) — — · — · —
charts/ChartLegend 48.7 kB (+3 B) · 224 B CSS (0) — — · — · —
CommandPalette 80.6 kB (+1 B) · 13.5 kB CSS (0) — — · — · —
ChatToolCalls 34.4 kB (0) · 8.8 kB CSS (0) — — · — · —
CommandPaletteInput 33.8 kB (0) · 7.9 kB CSS (0) — — · — · —
Heading 14.0 kB (0) · 5.8 kB CSS (0) — — · — · —
NavHeadingMenuItem 18.1 kB (0) · 6.7 kB CSS (0) — — · — · —
ProgressBar 12.1 kB (0) · 6.7 kB CSS (0) — — · — · —
Spinner 26.6 kB (0) · 6.6 kB CSS (0) — — · — · —
Text 13.2 kB (0) · 5.8 kB CSS (0) — — · — · —
Timer 15.3 kB (0) · 6.4 kB CSS (0) — — · — · —
lab/LineClamp 15.6 kB (0) · 168 B CSS (0) — — · — · —
ChatMessageList 30.1 kB (−1 B) · 7.4 kB CSS (0) — — · — · —
Timestamp 31.1 kB (−2 B) · 11.4 kB CSS (0) — — · — · —
layer — — — · ✓ · —
Layer — — ✓ · ✓ · —

Package size: @astryxdesign/core 7.83 MB packed (+4.2 kB); no new dependencies.

API changes: core +1 · ~0 · −0

1 API change (advisory)
Package Where Signature Usage
+ core . · Types · interface UsePopoverOptions anchorRef?: React.RefObject<Element | null> import type {UsePopoverOptions} from '@astryxdesign/core'; const x: UsePopoverOptions = {anchorRef: …}

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-a11y for Accessibility, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request is reviewed as part of its stack; see the review on #12891.

Automated review (maintainer link)

name: 'anchorRef',
type: 'React.RefObject<Element | null>',
description:
'External ref to use as the popover anchor: the element the popover sits on when it is not the trigger. Any element with a CSS box works (an HTML element or an <svg> element; a shape inside an <svg> warns in development). The trigger keeps its toggle and ARIA; the anchor gets neither and is never a trigger. The ref is read on open, on each render of your component, and on each show(). To move an open popover, set anchorRef.current and call show(). A show() while the ref holds no element waits, and opens when the ref is next read and holds one. With no trigger attached, open it with show(). Omit it and the trigger is the anchor.',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: with hasLightDismiss left on (the default), the press on another row closes the popover and show() opens it again, with a second onShow and initial focus (shows 2, hides 0 in Chromium and Firefox). The release note says so; this description and the anchorRef JSDoc do not. Suggested addition: "With light dismiss on, the press closes the popover first, and show() opens it again on the new element. Pass hasLightDismiss: false to move it without a close."

@nynexman4464

Copy link
Copy Markdown
Contributor Author

/approve-spec f42ee7f

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 19, 2026
@nynexman4464
nynexman4464 marked this pull request as ready for review November 19, 2026 17:57
@nynexman4464 nynexman4464 reopened this Nov 19, 2026
@nynexman4464

Copy link
Copy Markdown
Contributor Author

/approve-spec 4fb4c8b

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved: CI has finished on this head, and its only failures (test-node (3/9) and the test gate that collects it) come from a check that fails the same way on the base branch.

usePopover's new anchorRef matches spec:AST-116 FR1–FR3, FR5 and FR6, and the FR6 sentence and gap lines this pull request adds carry an engineering owner's /approve-spec at this head. The new tests, the interaction spec in Chromium and WebKit, and a Firefox run of the story all show the popover sitting on a cell, moving between rows with one onShow and no onHide, and hiding while its cell is gone.

  • The failing check is the swizzle sample test for the Lab MediaPlayer. It does not come from this change, but the merge guard needs it green, so it has to be fixed on main before this pull request can merge.
  • Optional: usePopover.doc.mjs and the anchorRef JSDoc could say what the changeset already says. With light dismiss on, a press on another row closes the popover and show() reopens it there, with a second onShow.
Claims and files checked

Review mode: full; reason: other:last review was a stack pointer

Changeset claims:

  • usePopover takes a ref to the element the popover sits on: verified (usePopover.tsx:187, :657-671).
  • Any element with a CSS box works, and a shape inside an <svg> warns in development: verified (table-cell and <svg> tests, warning test, popoverAnchor.ts:34-48).
  • The trigger keeps its toggle and ARIA, and the anchor gets neither: verified (first PopoverAnchor.test.tsx case).
  • The ref is read at open, on each render and on each show(): verified (usePopover.tsx:676-687, :742).
  • With light dismiss off, an open popover moves between rows without closing: verified (test; story run in Chromium and Firefox: 1 show, 0 hides).
  • With light dismiss on, the press closes it and show() reopens it on the new element: verified (story run: 2 shows, 0 hides).
  • A show() before the ref holds an element waits, then opens on the next read: verified (two waiting-open tests).
  • A composition with no trigger opens through show(): verified (trigger-less test).
  • The Popover component and its own anchorRef are unchanged: verified (Popover.tsx is not in the diff).

Description claims:

  • On the base, Popover's anchorRef must be a button and otherwise warns and never anchors: verified (Popover.tsx:955-990).
  • Nothing watches the page for a new element: verified (no observer added; the "does not watch the page" test).
  • An open popover with no anchor in the document paints no surface: verified (two tests; visibility: hidden in Chromium and Firefox).
  • There is no function form and no rectangle anchor: verified (the option's type).
  • One FR6 sentence is added, the FR1 gap is removed, FR6 and AR1 gaps are added and the FR9 gap is reworded: verified (record diff).
  • One optional option is added and no exported type: verified (API surface comparison: one added member).
  • An <svg> nested directly in another also warns: verified (warning test).
  • No default changes, and without the option the trigger is the anchor: verified (usePopover.tsx:648-656; the useLayer branches only run when anchorRef is set; 860 Popover and Layer tests pass).
  • The layer follows its anchor only through CSS anchor positioning: verified (no script positioning added).
  • In Chromium a move with light dismiss on shows twice and reports no hide, and the same row closes the popover with a hide: verified (Chromium and Firefox story runs).
  • The anchor test file has 19 tests covering the listed cases: verified (19 pass).
  • The tests fail when the named anchor drops a microtask late, or when the cleanup does not reset: verified (both mutations fail the named tests). The unmount test was not mutated on its own, and it also fails under the microtask mutation.
  • The interaction spec passes in Chromium and WebKit: verified (CI interaction jobs). Firefox was not covered by the pull request: verified, and this review covered it with a Firefox run.
  • The Popover and Layer suites pass, with 858 tests: verified in substance (860 at this head; the merge of the base brought two tests).
  • Typecheck, lint and the knowledge check pass: verified (CI typecheck and lint; the knowledge check passes locally).
  • The pull request was updated since the last review (emptied-ref fix, FR6 sentence, two more tests, two comments, updated with the base): verified (present at this head, which merges the base).
  • The writing rubric results hold: verified (each gap line names its requirement and the observable mismatch).
  • The first-load sizes are inside INV10's 307 B, and the warning is outside production bundles: verified (this review's build: +44, +55, +257, +32 and +246 B gzip; popoverAnchor.ts:34).

Files:

  • .changeset/popover-anchor.md: clear.
  • apps/storybook/stories/PopoverAnchorRef.stories.tsx: clear.
  • docs/specs/AST-116-popover-anchoring/spec.md: clear (approved at this head).
  • docs/specs/components/Popover/Popover.spec.md: clear.
  • packages/core/src/Layer/useLayer.tsx: clear.
  • packages/core/src/Popover/PopoverAnchor.test.tsx: clear.
  • packages/core/src/Popover/__tests__/PopoverAnchor.interaction.browser.spec.ts: clear.
  • packages/core/src/Popover/popoverAnchor.ts: clear.
  • packages/core/src/Popover/usePopover.doc.mjs: non-blocking doc note (light dismiss).
  • packages/core/src/Popover/usePopover.tsx: non-blocking doc note in the anchorRef JSDoc; otherwise clear.

Automated review (maintainer link)

@nynexman4464 nynexman4464 reopened this Nov 19, 2026
@nynexman4464 nynexman4464 reopened this Nov 19, 2026
@nynexman4464
nynexman4464 merged commit 0dad345 into main Nov 19, 2026
252 of 260 checks passed
@github-actions
github-actions Bot deleted the nynexman4464/feat/popover-anchor branch November 20, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — 4fb4c8b4 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant