Repository navigation
feat(usePopover): anchorRef names an anchor apart from the trigger (AST-116 FR1–FR3, FR5, FR6) - #11117
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'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 setshasLightDismiss={false}. usePopoverbuilds its own anchor-readiness path (isAnchorMissing, theunanchoredstyle and a raw documentMutationObserver,usePopover.tsx:596and:646-665) besideuseLayer's existing wait for a usable anchor and the sharedobserveMutationsutility, and extendinguseLayer'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), whilecomponent:PopoverORD2 says it follows the trigger, so keep the trigger as the width reference or have the owner amend ORD2 and document it onanchor.
A real-browser test of the late-anchor and width cases would close the gap the jsdom suite leaves.
[Automated review]
88e86f0 to
b905360
Compare
There was a problem hiding this comment.
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 setshasLightDismiss={false}. usePopoverbuilds its own anchor-readiness path (isAnchorMissing, theunanchoredstyle and a raw documentMutationObserver,usePopover.tsx:596and:646-665) besideuseLayer's existing wait for a usable anchor and the sharedobserveMutationsutility, and extendinguseLayer'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), whilecomponent:PopoverORD2 says it follows the trigger, so keep the trigger as the width reference or have the owner amend ORD2 and document it onanchor.
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.
e6927de to
e4cff57
Compare
b905360 to
199db1d
Compare
There was a problem hiding this comment.
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 setshasLightDismiss={false}. usePopoverbuilds its own anchor-readiness path (isAnchorMissing, theunanchoredstyle and a raw documentMutationObserver,usePopover.tsx:596and:646-665) besideuseLayer's existing wait for a usable anchor and the sharedobserveMutationsutility, and extendinguseLayer'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), whilecomponent:PopoverORD2 says it follows the trigger, so keep the trigger as the width reference or have the owner amend ORD2 and document it onanchor. - 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.
199db1d to
4a33324
Compare
There was a problem hiding this comment.
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 = anchorwrites a ref during render (usePopover.tsx:592), so useuseCommittedRef(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. usePopoveradds its own anchor-readiness state (isAnchorMissing,styles.unanchored) besideuseLayer'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
Elementand 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.tsxpasses 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:
usePopovertakes 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 throughonHide: 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
anchorRefmust 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.
0743846 to
ea2da64
Compare
4a33324 to
1c3386f
Compare
There was a problem hiding this comment.
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. usePopoveradds its own anchor-readiness state (isAnchorMissing,styles.unanchored) besideuseLayer'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.mjsand 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.tsxhas 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:
usePopovertakes ananchor, 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 throughonHide: 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
anchorRefkeeps its button requirement: verified (no Popover change in the diff, API delta has no Popover rows, suites pass). - Today a non-button
anchorRefwarns 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
mainand 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.
1c3386f to
d1fafde
Compare
There was a problem hiding this comment.
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:
anchoradds 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.mjssay ashow()before the anchor exists "waits until it does", but the wait ends only when the component that callsusePopoverrenders 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:
usePopovertakes ananchor, 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 throughonHide: 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
anchorRefkeeps its button requirement: verified (no Popover change; API delta lists three added rows only). - Today a non-button
anchorRefwarns 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
mainand 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 withoutanchor; 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).
There was a problem hiding this comment.
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
usePopoveranchors only to its trigger, and Popover's ownanchorRefmust 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 reportsonHideon 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.
…pec:AST-116 FR1–FR3, FR5, FR6)
bbff687 to
f42ee7f
Compare
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
This pull request is reviewed as part of its stack; see the review on #12891.
| 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.', |
There was a problem hiding this comment.
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."
|
/approve-spec f42ee7f |
|
/approve-spec 4fb4c8b |
There was a problem hiding this comment.
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
mainbefore this pull request can merge. - Optional:
usePopover.doc.mjsand theanchorRefJSDoc could say what the changeset already says. With light dismiss on, a press on another row closes the popover andshow()reopens it there, with a secondonShow.
Claims and files checked
Review mode: full; reason: other:last review was a stack pointer
Changeset claims:
usePopovertakes 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.tsxcase). - 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
anchorRefare unchanged: verified (Popover.tsxis not in the diff).
Description claims:
- On the base, Popover's
anchorRefmust 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: hiddenin 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; theuseLayerbranches only run whenanchorRefis 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 theanchorRefJSDoc; otherwise clear.
Stack: #11117 → #11121 → #13015
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
usePopoveranchors only to its trigger, and Popover'sanchorRefmust be a button (a<button>or an element withrole="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
usePopoverinput,anchorRef, names the element the layer sits on; the trigger keeps its own job. ThePopovercomponent does not change (AST-116 DEC-8).anchorRefis 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.usePopover, and on eachshow(). Nothing watches the page for a new element (FR3). A caller that moves an open popover setsanchorRef.currentand callsshow(). WithhasLightDismiss: falsethe popover moves without a close or remount. With light dismiss on, the press on the other control closes it first andshow()opens it again on the new element (theFR9 gap:line below).anchorRefand no trigger opens throughshow()and reports dismissals throughonHide(FR5).There is no function form and no rectangle anchor (AST-116 DEC-1).
Current specification
spec:AST-116FR1–FR3, FR5, FR6, DEC-1 and DEC-8 (current, onmain). This PR adds one sentence to FR6 (ashow()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: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
beforetoggleto closed and then to open, a secondonShowand noonHidefor a press on another row's button, and a close withonHidefor a second press on the same row's button.Public delta and caller burden
anchorRef?: React.RefObject<Element | null>onUsePopoverOptions. No new exported type.<svg>, or an<svg>nested directly in another, is not an anchor (it has no CSS box); passing one warns once in development.anchorRef, the trigger is the anchor exactly as before.PopoverPropsis unchanged; Popover's ownanchorRefkeeps its meaning and its button requirement.Before (a stand-in button kept over the cell):
After:
Design and alternatives
show(). No observer watches the document for a new element.architecture:layer-runtimeINV21).Ref, and widening Popover'sanchorRefto non-buttons. Rejected (DEC-8): a position-only anchor on thePopovercomponent.Evidence
PopoverAnchor.test.tsx(all throughusePopover), 19 tests:aria-expanded,aria-haspopupandaria-controls; the anchor gets no ARIA, and a press on it does not open the popover;anchorRefis dropped;show()and itsonHideon dismissal;<svg>inside an<svg>, and none for an outer<svg>or one inside<foreignObject>;<svg>element as anchors;show()called while open (light dismiss off): the anchor name moves, the surface node is the same,onHideis not called, and focus stays on the field it was in;show()while the ref is empty waits, and opens on the nextshow()once the ref holds an element, and on the next render when React attaches the ref;show()on such a ref waits;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;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);Real browser,
PopoverAnchor.interaction.browser.spec.tson the newCore/Popover Anchor Refstory, 2 of 2 in Chromium and in WebKit:show()runs, the same surface node sits beside that cell, still open, with the value typed into it, one show and no hide;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
Testing
pnpm exec vitest run --project ui packages/core/src/Popover/PopoverAnchor.test.tsx: 19 passedpnpm exec vitest run --project ui packages/core/src/Popover packages/core/src/Layer: 858 passedpnpm test:interaction PopoverAnchor.interaction.browser.spec.ts --project chromium, and the same spec in WebKit: 2 passed eachtsc --noEmit(core): cleanpnpm check:knowledge: passestest-uishards: passChanges since the last review
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 thatshow()waits. The layer's separate check for a disconnected element is gone: the same path covers it.spec:AST-116FR6 gains one sentence: ashow()while the ref holds no element in the document does not open the popover; it opens, and reportsonShow, 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.StrictMode.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; theFR1 gap:line is removed,FR6 gap:andAR1 gap:are added andFR9 gap:is reworded inspec:AST-116, andcomponent:Popoverdrops one "FR1 gap there" pointer and gains one "FR6 gap there" pointer.First-load size (INV10)
pnpm size:pages --page popover=Popover,Button,Text, this PR's change in gzip bytes againstmain:anchorRefis 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) thatarchitecture:component-import-boundariesINV10 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.