Repository navigation
feat(usePopover): onOutsidePress can keep a popover open (AST-116 FR9–FR11) - #11132
nynexman4464 wants to merge 1 commit into
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 on the spec. onOutsidePress, PopoverOutsidePressEvent and the switch to a manual popover they bring rest only on draft spec:AST-113 FR9–FR11 and DEC-4, and no current record decides them. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. The decision should also settle two things: the Popover record's "Light and Escape dismissal" row and the layer runtime's dismissal plumbing, which describe only native popover="auto", and the fact that a manual popover no longer closes when another auto popover opens.
These need fixing whatever the spec decision:
- Changing whether
onOutsidePressis set while the popover is open flips the layer betweenpopover="manual"andpopover="auto", which closes it and reportsonOpenChange(false)with no press (usePopover.tsx:578-581), so keep the mode fixed while it is open and add a test. - The outside-press watch starts in an Effect keyed on the open state (
usePopover.tsx:744-770) instead of the layer's show callback, unlike every other caller ofuseOutsidePress, so start it inhandleLayerShow, stop it inonHide, and delete the Effect.
5fc7a19 to
b19b6a1
Compare
3cf6201 to
e91b0ff
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the spec: onOutsidePress, PopoverOutsidePressEvent and the switch to a manual popover they bring are proposed only by the draft spec:AST-116 (FR9–FR11, DEC-4), and no current record decides them. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. The decision should also cover what the manual popover changes beyond the veto: the Popover record's "Light and Escape dismissal" row and the layer runtime's list of manual popovers describe only native popover="auto", another auto popover that opens without a press no longer closes this one, a portaled nested layer counts as outside, and after a vetoed press focus sits outside a popover that keeps aria-modal. Independent of that decision, these need fixing:
- Adding or removing
onOutsidePresswhile the popover is open flips the layer betweenpopover="manual"andpopover="auto", which closes it and reportsonOpenChange(false)with no press (usePopover.tsx:578-581), so keep the mode fixed while it is open and add a test. - The outside-press watch starts in an Effect keyed on the open state (
usePopover.tsx:744-770) instead of the layer's show callback, unlike every other caller ofuseOutsidePress, so start it inhandleLayerShow, stop it in a wrappedonHide, and delete the Effect.
e91b0ff to
e18f427
Compare
b19b6a1 to
d219845
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the spec: onOutsidePress, PopoverOutsidePressEvent and the manual popover they bring are proposed only by the draft spec:AST-116 (FR9–FR11, DEC-4), and no current record decides them. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner. The decision should also cover what the manual popover changes beyond the veto: the Popover record's "Light and Escape dismissal" row and the layer runtime's list of the watch's owners, the auto-popover stack, portaled nested layers, focus left outside an aria-modal popover after a vetoed press, and a modal host that closes on a vetoed backdrop press. Independent of that decision, these need fixing:
- Adding or removing
onOutsidePresswhile the popover is open flips the layer betweenpopover="manual"andpopover="auto", which closes it with no press (usePopover.tsx:576-579), so keep the mode fixed while it is open and add a test that changes the callback while open. - The outside-press watch starts in an Effect keyed on the open state (
usePopover.tsx:721-749) instead of the layer's show callback, so start it inhandleLayerShow, stop it in a wrappedonHide, and delete the Effect. - Newly live check:
onOutsidePressRef.currentandhideRef.currentare written during render (usePopover.tsx:716-719), so keep both throughuseCommittedRef, which is onmain. - Newly live check: the veto code adds first-load JavaScript to every page that renders Popover,
usePopoveror DropdownMenu without the option (about 1 KB gzip against this branch's base, and about 0.35 KB where the outside-press watch already loads, as onmain), over the 0.3 KB an optional feature may cost, so load it only when a caller passesonOutsidePressand report the per-page deltas. - The description says the outside-press watch is already used by ContextMenu, Typeahead and Tooltip, but its users are BaseTypeahead, DateInput, DateTimeInput and the Chat trigger menu, so correct that sentence.
Claims and files checked
Review mode: full; reason: rebase
- Claim:
usePopoveracceptsonOutsidePress: verified (usePopover.tsx:351). - Claim: it runs for each press that starts and ends outside, before the popover closes: verified (
usePopover.tsx:723-749; test "reports an outside press"). - Claim:
preventDefault()keeps the popover open: verified (test "stays open when the press is cancelled"; Chromium at this head). - Claim: the press, its focus change and its click still reach the page: verified (the watch never cancels or stops the event,
outsidePress.ts:99-197; the test checks the pointerup is not cancelled). - Claim: a press on a separate anchor is outside and a press on the trigger is not reported: verified (
usePopover.tsx:731-736; tests). - Claim: never called with light dismiss off, for Escape or for the fallback close: verified (
usePopover.tsx:576,:598,:864; tests). - Claim: the event carries the target and pointer type and no browser event: verified (
usePopover.tsx:364-390; test). - Claim: one new option and one new exported type, with
PopoverPropsunchanged: verified (generated API delta;Popover.tsxuntouched). - Claim: without a callback nothing changes and the layer stays
popover="auto": verified for behavior (test); the bundle cost is a finding above. - Claim: with a callback the layer is manual on the watch already used by ContextMenu, Typeahead and Tooltip: false in part (finding above).
- Claim: Escape stays registered through the focus trap: verified (
usePopover.tsx:598). - Claim: the watch hands its owner the ending event and a declined press is not counted: verified (
outsidePress.ts:84-92;outsidePress.test.ts). - Claim: a nested layer portaled outside the popover counts as outside and one rendered inside is inside: verified (
usePopover.tsx:728-736). - Claim: the two test files pass with 31 tests, and eslint is clean: verified; the typecheck was not rerun.
- Claim: the three-engine browser run used the earlier component-prop shape and was not rerun: stated as such; the row switch reproduces in Chromium at this head.
- Changeset: the same claims as above: verified.
- File
.changeset/popover-outside-press.md: clear. - File
packages/core/src/Layer/outsidePress.ts: clear (existing owners never returnfalse). - File
packages/core/src/Layer/outsidePress.test.ts: clear. - File
packages/core/src/Popover/usePopover.tsx: the first four findings above. - File
packages/core/src/Popover/PopoverOutsidePress.test.tsx: clear. - File
packages/core/src/Popover/index.ts: clear. - File
packages/core/src/Popover/usePopover.doc.mjs: clear (matches the code).
e18f427 to
370ea23
Compare
d219845 to
7e1a86d
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the spec, and four fixes are needed whatever that decision is.
onOutsidePress, PopoverOutsidePressEvent and the manual popover they bring are proposed by spec:AST-116 FR9–FR11 and DEC-4, which are not on main yet; the record's only /approve-spec names an earlier head of #11112, and this pull request has none at its head. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), covering the API, the veto behavior and the manual mode's differences from native light dismiss: another auto popover that opens without a press no longer closes it, a portaled nested layer counts as outside, focus can stay outside a popover that keeps aria-modal="true" after a vetoed press, and a vetoed press on a modal Dialog's or Drawer's backdrop closes the host.
Fixes needed:
- Removing or adding
onOutsidePresswhile the popover is open closes it, because the layer'spopoverattribute follows the callback (usePopover.tsx:601-604); keep the mode fixed while open and add a test that changes the callback while open. - The outside-press watch starts in an Effect keyed on the open state (
usePopover.tsx:749-791), againstarchitecture:react-component-runtimeINV2 and INV3; start it inhandleLayerShowand stop it in a wrappedonHide, asuseOutsidePressdocuments and BaseTypeahead and Selector do. - A page that renders
PopoverwithoutonOutsidePressgrows 328 B gzip of first-load JavaScript (aDropdownMenupage 327 B), over the 307 B thatarchitecture:component-import-boundariesINV10 allows; move the veto behind its own import or a deferred load and report the Popover page delta. component:Popover's Dismissal and 'Light and Escape dismissal' rows (Popover.spec.md:146,:166) and AST-116's Current-state impact (spec.md:289) still say native light dismiss holds until FR9 ships and point to theFR9 gapline this pull request deletes; update them to describe the manual watch for anonOutsidePresscaller.
The render-time refs and the description's list of the watch's users are now fixed.
Claims and files checked
Review mode: full; reason: rebase
- Claim: the callback runs before an outside press closes the popover, and cancelling keeps it open: verified (new usePopover tests; a Chromium row-editor check at this head).
- Claim: the event carries only the pressed element and pointer type, and cancelling leaves the press itself alone: verified (
usePopover.tsx:765-773; the "stays open" test asserts the pointerup is not cancelled). - Claim: a press on a separate anchor is outside and a press on the trigger is not reported: verified (tests;
usePopover.tsx:757-762). - Claim: never called with light dismiss off, for Escape or for the fallback close: verified (tests;
usePopover.tsx:601,:627). - Claim: a touch that pans is not reported: verified (pan test;
outsidePress.ts:179-183). - Claim: without a callback the layer stays native auto, with one it is manual: verified (two tests).
- Claim: the watch is used by Typeahead, Selector, DateInput, DateTimeInput and the Chat trigger menu: verified (their imports of
useOutsidePress). - Claim: the watch hands its owner the ending event and does not count a declined press: verified (
outsidePress.ts:118-126; new watch test). - Claim: a nested layer portaled outside counts as outside, as for the other watch users: verified (
usePopover.tsx:757-762; the text fields' inside test). - Claim: nine tests in the new file, and the focused tests pass: verified (9 cases; the Popover, Layer, Typeahead, DateInput, DateTimeInput, Dialog, Drawer, DropdownMenu, Selector and Chat suites pass).
- Claim: core typecheck and lint are clean: verified.
- Claim: first-load deltas docs +0, form +0, menu +305, table +0, within the 307 B allowance: verified, but a Popover page grows +328 B (finding).
- Claim: the spec's FR9 gap line is deleted because this pull request meets it: verified, but other record rows still point to it (finding).
- Claim: the real-browser run used the earlier component shape and was not repeated: taken as stated; not a current-spec requirement.
- Changeset: called for each outside press before closing, cancelling keeps it open, the press still reaches the page, anchor outside, trigger not, a pan is not a press: verified.
- File
.changeset/popover-outside-press.md: clear. - File
docs/specs/AST-116-popover-anchoring/spec.md: finding (stale rows elsewhere). - File
packages/core/src/Layer/outsidePress.ts: clear. - File
packages/core/src/Layer/outsidePress.test.ts: clear. - File
packages/core/src/Popover/PopoverOutsidePress.test.tsx: clear. - File
packages/core/src/Popover/index.ts: clear. - File
packages/core/src/Popover/usePopover.doc.mjs: clear. - File
packages/core/src/Popover/usePopover.tsx: findings (mode flip, Effect, first-load size).
370ea23 to
73ea344
Compare
7e1a86d to
6b78b17
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the spec, and two fixes are needed whatever that decision is.
onOutsidePress, PopoverOutsidePressEvent and the manual popover they bring are proposed by spec:AST-116 FR9–FR11 and DEC-4, which are not on main yet, and this pull request has no /approve-spec at its head. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), covering the API, the veto behavior, the component:Popover row edits and the manual mode's differences from native light dismiss.
Fixes needed:
- A callback first passed in the update that opens the popover, or while it is open, is never called and native light dismiss closes the popover on that press, while the JSDoc,
usePopover.doc.mjsand the changeset promise a call for each outside press (usePopover.tsx:623-625,:800-802); say that the callback is read as the popover opens and holds until it closes, and add a test that sets it in the opening update. - A page that renders
PopoverwithoutonOutsidePressgrows 328 B gzip and the menu reference page 332 B, over the 307 B thatarchitecture:component-import-boundariesINV10 allows (usePopover.tsx:35); move the veto behind its own import or a deferred load, unless an engineering owner records the INV10 exception the description asks for.
Adding or removing the callback while open, the open-state Effect and the stale record rows are now fixed.
Claims and files checked
Review mode: full; reason: rebase
- Claim: the callback runs for each press that starts and ends outside the open popover, before it closes: false for a callback first passed as the popover opens or while it is open (finding); true otherwise (tests; a Chromium row-editor check).
- Claim: cancelling keeps the popover open: verified (tests; Chromium).
- Claim: the event carries only the pressed element and pointer type, and cancelling leaves the press itself alone: verified (the "stays open" test asserts the pointerup is not cancelled and no native event).
- Claim: a press on a separate anchor is outside, and a press on the trigger is not reported: verified (tests;
usePopover.tsx:815-820). - Claim: never called with light dismiss off, for Escape or for the fallback close: verified (tests; the close control sits inside the surface).
- Claim: one new optional option and one new exported type, with
Popover's props unchanged: verified (API surface generator over base and head builds). - Claim: without a callback the layer stays native auto, with one it is manual: verified (two tests).
- Claim: the watch is shared with Typeahead, Selector, DateInput, DateTimeInput and the Chat trigger menu, and Escape stays on the focus trap: verified (their imports;
usePopover.tsx:653). - Claim: the watch hands its owner the ending event and does not count a declined press: verified (
outsidePress.ts:118-126; new watch test). - Claim: a nested layer portaled outside counts as outside: verified (
usePopover.tsx:815-820). - Claim: the new test file covers the listed cases, including a touch pan and a callback change while open, and the focused tests pass: verified (10 cases; the Popover, Layer, Typeahead, DateInput, DateTimeInput, Selector, Dialog, Drawer, DropdownMenu and Chat suites pass).
- Claim: core typecheck and lint are clean: verified.
- Claim: the real-browser run used the earlier component shape and was not repeated: taken as stated; a Chromium check at this head agrees with it.
- Claim: since the last review, pans are ignored, the mode holds while open, the watch starts on show and stops on hide, and the records name the scripted watch: verified (code; new test).
- Claim: first-load deltas docs +0, form +0, menu +332, table +0, popover +328, over the allowance: verified with the size script over both builds (finding).
- Claim: holding the mode and starting the watch on show cost about 30 B: not checked separately.
- Changeset: called for each outside press before closing: false for a callback first passed as the popover opens (finding); cancelling keeps it open, the press still reaches the page, anchor outside, trigger not, a pan is not a press: verified.
- File
.changeset/popover-outside-press.md: finding (each-press claim). - File
docs/specs/AST-116-popover-anchoring/spec.md: clear. - File
docs/specs/components/Popover/Popover.spec.md: non-blocking note (build-status wording in two rows). - File
packages/core/src/Layer/outsidePress.ts: clear. - File
packages/core/src/Layer/outsidePress.test.ts: clear. - File
packages/core/src/Popover/PopoverOutsidePress.test.tsx: clear. - File
packages/core/src/Popover/index.ts: clear. - File
packages/core/src/Popover/usePopover.doc.mjs: finding (each-press claim). - File
packages/core/src/Popover/usePopover.tsx: findings (callback read at open; first-load size).
| | Visibility ownership | Uncontrolled or externally controlled | Chooses whether Popover stores visibility or synchronizes to caller state | Popover | Uncontrolled | `component:Popover` | Current public behavior | Controlled changes are synchronized through show/hide; dismissal requests are reported to the caller rather than redefining the external source of truth. | | ||
| | Popup semantics | Dialog or neutral wrapper | Exposes dialog semantics or lets child menu/listbox semantics own the popup | Popover and hook | Dialog | `component:Popover` | Current public behavior | A dialog without a label warns in development. Neutral mode omits dialog role and modal semantics. | | ||
| | Focus entry | Automatic or caller-preserved | Focuses genuine caller content, falls back to the labeled dialog surface when none exists, or preserves current focus | Popover and hook | Automatic | `component:Popover` | Current public behavior | The injected fallback close control is excluded from initial-focus candidates and reveals only when reached sequentially. | | ||
| | Dismissal | Outside/Escape enabled or disabled within native constraints | Controls light dismiss and explicit Escape participation | Popover and hook | Both enabled | `component:Popover`; `family:overlay-dismissal` owns Escape/platform-close ordering | Current public behavior | Disabling Escape alone cannot override the native Escape behavior of an auto popover; explicit-dismiss behavior requires light dismiss to be disabled too. A `usePopover` caller with `onOutsidePress` gets a scripted outside-press watch instead of native auto light dismiss (`spec:AST-116` FR9); Escape applies wherever focus is until `spec:AST-116` FR15 ships (FR15 gap there). | |
There was a problem hiding this comment.
Non-blocking: "until spec:AST-116 FR15 ships" is build status, here and in the 'Light and Escape dismissal' row (line 166). Keep only the gap pointer, for example "Escape applies wherever focus is (spec:AST-116 FR15 gap)."
73ea344 to
32ef02e
Compare
6b78b17 to
6e209c9
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the spec, and two fixes are needed whatever that decision is.
onOutsidePress, PopoverOutsidePressEvent and the manual popover they bring are proposed by spec:AST-116 FR9–FR11 and DEC-4, which are not on main yet, and this pull request has no /approve-spec at its head. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner), covering the API, the veto behavior, the component:Popover row edits and the manual mode's differences from native light dismiss.
Fixes needed:
- Miss: when
hasLightDismissturns false while the popover is open, the watch started at open keeps running, so the next outside press still callsonOutsidePressand closes the popover, although the JSDoc andusePopover.doc.mjssay it is not called with light dismiss off (usePopover.tsx:796-836); readhasLightDismissin the watch's callback through a committed ref (or stop the watch when it turns off) and add a test that turns it off while open. - A page that renders
PopoverwithoutonOutsidePressgrows 314 B gzip and the menu reference page 329 B, over the 307 B thatarchitecture:component-import-boundariesINV10 allows (usePopover.tsx:35); move the veto behind its own import or a deferred load, unless an engineering owner records the INV10 exception the description asks for.
Reading the callback at open is now documented and tested, and the earlier mode-flip and stale-row fixes still hold.
Claims and files checked
Review mode: full; reason: rebase
- Claim: the callback runs for each press that starts and ends outside the open popover, before it closes: verified (tests; a Chromium filter-panel check).
- Claim: cancelling keeps the popover open: verified (tests; Chromium).
- Claim: the event carries only the pressed element and pointer type, and cancelling leaves the press itself alone: verified (the "stays open" test asserts the pointerup is not cancelled and no native event; in Chromium the vetoed press still ran its click).
- Claim: a press on a separate anchor is outside, and a press on the trigger keeps its toggle and is not reported: verified (tests;
usePopover.tsx:811-816). - Claim: never called with light dismiss off: false when light dismiss turns off while the popover is open (finding); true when it is off before opening (test; Chromium).
- Claim: Escape and the fallback close are not outside presses: verified (Escape test; the close control sits inside the surface).
- Claim: one new optional option and one new exported type, with
Popover's props unchanged: verified (API surface generator over base and head builds). - Claim: without a callback the layer stays native auto, with one it is manual, and Escape stays on the focus trap: verified (two tests;
usePopover.tsx:662). - Claim: the watch is shared with Typeahead, Selector, DateInput, DateTimeInput and the Chat trigger menu: verified (their imports).
- Claim: the watch hands its owner the ending event and does not count a declined press: verified (
outsidePress.ts:118-126; new watch test). - Claim: a nested layer portaled outside counts as outside while a callback is set: verified (
usePopover.tsx:808-816). - Claim: the callback is read from the last render before opening and holds until close: verified (code; the new test).
- Claim: the focused tests pass, and core typecheck and lint are clean: verified (the Popover and Layer suites with the watch's users, 145 files; typecheck; lint).
- Claim: the real-browser run used the earlier component shape and was not repeated: taken as stated; a Chromium check at this head agrees for the veto.
- Claim: the whole-project run lives in a later pull request: not checked here.
- Claim: first-load deltas docs +0, form +0, menu +331, table +0, popover +314, over the allowance: verified within 2 B (menu +329 here) with the size script over both builds (finding).
- Claim: a deferred load did not help: not checked.
- Changeset: called for each outside press before closing, set before opening, cancelling keeps it open, the press still reaches the page, anchor outside, trigger not, a pan is not a press: verified.
- File
.changeset/popover-outside-press.md: clear. - File
docs/specs/AST-116-popover-anchoring/spec.md: non-blocking note (build-status wording). - File
docs/specs/components/Popover/Popover.spec.md: non-blocking note (build-status wording in two rows). - File
packages/core/src/Layer/outsidePress.ts: clear. - File
packages/core/src/Layer/outsidePress.test.ts: clear. - File
packages/core/src/Popover/PopoverOutsidePress.test.tsx: clear. - File
packages/core/src/Popover/index.ts: clear. - File
packages/core/src/Popover/usePopover.doc.mjs: finding (the light-dismiss claim). - File
packages/core/src/Popover/usePopover.tsx: findings (light dismiss turned off while open; first-load size).
32ef02e to
25310be
Compare
6e209c9 to
fbe01d5
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the spec, and one fix is needed whatever that decision is.
onOutsidePress, PopoverOutsidePressEvent and the manual popover they bring are proposed by spec:AST-116 FR9–FR11 and DEC-4, which are not on main yet; the spec's own pull request has an engineering owner's approval for its head, but this pull request has no /approve-spec at its head, and that decision also has to cover its component:Popover row edits and the manual mode's differences from native light dismiss. An engineering owner records the decision by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner).
Fix needed:
- A page that renders
PopoverwithoutonOutsidePressgrows 360 B gzip of first-load JavaScript and the menu reference page 332 B, over the 307 B thatarchitecture:component-import-boundariesINV10 allows (usePopover.tsx:35); move the veto behind its own import or a deferred load, unless an engineering owner records the INV10 exception the description asks for.
Turning hasLightDismiss off while the popover is open now stops both the callback and the close, and the earlier fixes still hold.
Claims and files checked
Review mode: full; reason: rebase
- Claim: the callback runs for each press that starts and ends outside the open popover, before it closes: verified (tests; a Chromium filter-panel check).
- Claim: cancelling keeps the popover open: verified (tests; Chromium).
- Claim: the event carries only the pressed element and pointer type, and cancelling leaves the press itself alone: verified (the "stays open" test asserts the pointerup is not cancelled and no native event).
- Claim: a press on a separate anchor is outside, and a press on the trigger keeps its toggle and is not reported: verified (tests;
usePopover.tsx:833-838). - Claim: never called with light dismiss off, and Escape and the fallback close are not outside presses: verified (tests;
usePopover.tsx:637,:841-843). - Claim: light dismiss turned off while open stops the watch, read at press time, and the new test fails without the change: verified (
usePopover.tsx:819-843; the test; without the guard its callback runs and the popover closes; Chromium: open, 0 calls). - Claim: one new optional option and one new exported type, with
Popover's props unchanged: verified (API surface generator over base and head builds). - Claim: without a callback the layer stays native auto, with one it is manual, and Escape stays on the focus trap: verified (two tests;
usePopover.tsx:642,:667). - Claim: the watch is shared with Typeahead, Selector, DateInput, DateTimeInput and the Chat trigger menu: verified (their imports).
- Claim: the watch hands its owner the ending event and does not count a declined press: verified (
outsidePress.ts:118-126; new watch test). - Claim: a nested layer portaled outside counts as outside while a callback is set: verified (
usePopover.tsx:830-838). - Claim: the callback is read from the last render before opening and holds until close: verified (code; test).
- Claim: a boolean predicate was rejected as a design: a design statement, not checkable.
- Claim: the focused tests pass, and core typecheck and lint are clean: verified (the Popover and Layer suites with the watch's users and the components that render the hook, 177 files; typecheck; lint).
- Claim: the real-browser run used the earlier component shape and was not repeated: taken as stated; a Chromium check at this head agrees for the veto.
- Claim: the whole-project run lives in a later pull request: not checked here.
- Claim: first-load deltas docs +0, form +0, menu +332, table +0, popover +360, over the allowance: verified exactly with the size script over both builds (finding).
- Claim: a deferred load did not help: not checked.
- Claim: the spec's own pull request has an engineering owner's approval for its head: verified for that pull request's current head; it does not cover this head.
- Changeset: called for each outside press before closing, set before opening, cancelling keeps it open, the press still reaches the page, anchor outside, trigger not, a touch that pans is not a press: verified.
- File
.changeset/popover-outside-press.md: clear. - File
docs/specs/AST-116-popover-anchoring/spec.md: clear (its edits wait on the spec decision). - File
docs/specs/components/Popover/Popover.spec.md: non-blocking note (build-status wording in two rows); its row edits wait on the spec decision. - File
packages/core/src/Layer/outsidePress.ts: clear. - File
packages/core/src/Layer/outsidePress.test.ts: clear. - File
packages/core/src/Popover/PopoverOutsidePress.test.tsx: clear. - File
packages/core/src/Popover/index.ts: clear. - File
packages/core/src/Popover/usePopover.doc.mjs: clear. - File
packages/core/src/Popover/usePopover.tsx: finding (first-load size); non-blocking comment note.
| // from closing the popover or calling `onOutsidePress`. | ||
| const hasLightDismissRef = useCommittedRef(hasLightDismiss); | ||
| const hideRef = useCommittedRef(layer.hide); | ||
| // Watches the document for outside presses while the popover is open. The |
There was a problem hiding this comment.
Non-blocking: the first sentence restates what startOutsidePress does. Keep only the reason: "The trigger counts as inside, so its own toggle answers a press on it."
25310be to
48a1e5f
Compare
fbe01d5 to
e93da3d
Compare
There was a problem hiding this comment.
Approval waits on an engineering owner's decision on the spec, and one fix is needed if the option stays.
onOutsidePress, PopoverOutsidePressEvent and the manual popover they bring are proposed by spec:AST-116 FR9–FR11 and DEC-4, which are not on main yet; the spec's own pull request is approved at its head, but this pull request has no /approve-spec at its head, and the description now says the option is being dropped. An engineering owner either confirms that, so this pull request can be closed, or approves the option, its manual-mode behavior and its component:Popover row edits by commenting /approve-spec <full head SHA> here (the author may do so as an engineering owner).
Fix needed:
- A page that renders
PopoverwithoutonOutsidePressgrows 360 B gzip of first-load JavaScript and the menu reference page 331 B, over the 307 B thatarchitecture:component-import-boundariesINV10 onmainallows (usePopover.tsx:35); this clears if the stack's INV10 exception foronOutsidePresslands onmainfirst, otherwise move the veto behind its own import or a deferred load.
Claims and files checked
Review mode: full; reason: rebase
- Claim: the stack's spec is being revised after owner review so that the option is not implemented, and this pull request will be replaced by a rule with no callback: not checkable here; no record or comment states it, and the spec pull request's approved head still includes the option.
- Claim: this head only carries a rebase: verified (the pull request's own added and removed lines are identical to the previous head's; only hunk positions and one context line from the base moved).
- Claim: the stack's spec is proposed, not on
main, and an engineering owner approved its head: verified. - Claim: the callback runs for each press that starts and ends outside the open popover, before it closes: verified (tests; a Chromium filter-panel check).
- Claim:
event.preventDefault()keeps the popover open: verified (tests; Chromium). - Claim: the event carries only the pressed element and pointer type, and cancelling leaves the press itself alone: verified (the "stays open" test asserts the press is not cancelled and no native event).
- Claim: a press on a separate anchor is outside, and a press on the trigger keeps its toggle and is not reported: verified (tests;
usePopover.tsx:833-838). - Claim: never called with light dismiss off, and Escape and the fallback close are not outside presses: verified (tests;
usePopover.tsx:667,:841-843). - Claim: one new optional option and one new exported type, with
Popover's props unchanged: verified (API surface generator over base and head builds). - Claim: without a callback the layer stays native auto, with one it is manual, and Escape stays on the focus trap: verified (two tests;
usePopover.tsx:642,:667). - Claim: the watch is shared with Typeahead, Selector, DateInput, DateTimeInput and the Chat trigger menu: verified (their imports).
- Claim: the watch hands its owner the ending event and does not count a declined press: verified (
outsidePress.ts:118-126; new watch test). - Claim: a nested layer portaled outside counts as outside while a callback is set: verified (
usePopover.tsx:833-838). - Claim: a boolean predicate was rejected as a design: a design statement, not checkable.
- Claim: the focused tests pass, including the touch-pan and callback-switch cases, and core typecheck and lint are clean: verified (the Popover and Layer suites with the watch's users, 141 files; typecheck; lint).
- Claim: the real-browser run used the earlier component shape and was not repeated: taken as stated; a Chromium check at this head agrees for the veto.
- Claim: the whole-project run lives in a later pull request: not checked here.
- Claim: light dismiss turned off while open stops the watch, read at press time, with a test that fails without the change: verified (
usePopover.tsx:821,:841-843; the test passes; Chromium: open, 0 calls; the failure without the guard was checked at the previous head, whose code is identical). - Claim: the stack's spec keeps this input in
usePopoverat its measured cost and names an INV10 exception, decided by an engineering owner: verified in the stack's approved spec; not onmain. - Claim: first-load deltas docs +0, form +0, menu +332, table +0, popover +360, over 0.3 KB and inside the 0.4 KB exception: verified within 1 B (menu measured +331) with the size script over both builds (finding against
main). - Claim: a deferred load did not help, and the whole-stack size numbers: not checked.
- Changeset: called for each outside press before closing, set before opening, cancelling keeps it open, the press still reaches the page, anchor outside, trigger not, a touch that pans is not a press: verified.
- File
.changeset/popover-outside-press.md: clear. - File
docs/specs/AST-116-popover-anchoring/spec.md: clear (its edits wait on the spec decision). - File
docs/specs/components/Popover/Popover.spec.md: non-blocking note (build-status wording in two rows); its row edits wait on the spec decision. - File
packages/core/src/Layer/outsidePress.ts: clear. - File
packages/core/src/Layer/outsidePress.test.ts: clear. - File
packages/core/src/Popover/PopoverOutsidePress.test.tsx: clear. - File
packages/core/src/Popover/index.ts: clear. - File
packages/core/src/Popover/usePopover.doc.mjs: clear. - File
packages/core/src/Popover/usePopover.tsx: finding (first-load size); non-blocking comment note.
User need
Outside presses close a popover through native
popover="auto"light dismiss, which no script can cancel. Some presses outside a popover are not requests to close it. In a table, pressing another row's edit control while the editor is open should move the editor to that row, not close it and make the person press again. With a shared filter panel, pressing another column header should switch the panel. Today the only choice is all or nothing (hasLightDismiss).Problem and solution fit
usePopover'sonOutsidePress(event)(AST-116 FR9–FR11, DEC-4, DEC-8):event.preventDefault()keeps the popover open.target,pointerType) and carries no browser event, so cancelling never cancels the press: its focus change and click reach the page unchanged.anchoris outside. A press on the trigger keeps its released toggle and is not reported.hasLightDismiss: falseit is never called. Escape and the fallback close are not outside presses.Current specification
spec:AST-116FR9–FR11, DEC-4, DEC-8 (proposed in #11112; not onmainyet).Public delta and caller burden
onOutsidePress?: (event: PopoverOutsidePressEvent) => voidonUsePopoverOptions; new exported typePopoverOutsidePressEvent.PopoverPropsis unchanged.popover="auto"(asserted).popover="manual"and the core outside-press watch (used by Typeahead, Selector, DateInput, DateTimeInput and the Chat trigger menu) decides outside presses. Escape stays registered through the focus trap.watchOutsidePresshands itsonOutsidethe ending event, and afalsereturn means the layer stayed open. Such a press is not counted as an outside dismissal, so a modal host's backdrop handler (family:overlay-dismissalFR11) does not mistake a vetoed press for a closed layer.Design and alternatives
Rejected (AST-116 DEC-4): a boolean predicate prop, which names no event and cannot grow a target or pointer type later.
Known difference while a callback is set: a layer nested in this popover but portaled outside its DOM subtree counts as outside, as it does for the other components that use the outside-press watch. A layer rendered inside the popover (the default) is inside.
Evidence
PopoverOutsidePress.test.tsx(with the touch-pan and callback-switch cases):hasLightDismiss: falsenever calls it;autowithout a callback,manualwith one.outsidePress.test.ts: a declined press is handed the ending event and not counted.<Popover onOutsidePress>shape (the same hook path; not re-run since the move tousePopoveronly) (script and screenshots): pressing another row's pencil is vetoed while the popover moves to that row; a press elsewhere closes it. WebKit 26.5 (Playwright WebKit on macOS) passes the same checks.Scope
Components: usePopover, Layer outside-press watch (internal)
Testing
pnpm exec vitest run --project ui packages/core/src/Popover/PopoverOutsidePress.test.tsx packages/core/src/Layer/outsidePress.test.ts: passeduiproject at the top of the stack: see feat(usePopover): tabBehavior lets Tab pass through a popover (spec:AST-116 FR12–FR15, AR4) #11156tsc --noEmit(core), eslint: cleanChanges since the last review
onOutsidePressnor closes the popover.hasLightDismissis read at press time. Test: "stops reporting and closing when light dismiss turns off while open" (fails without the change).usePopoverat its measured cost, and INV10 names the exception; see below.First-load size (INV10)
pnpm size:pages --page popover=Popover,Button,Text, this PR's change in gzip bytes against the PR below it (whole stack against the spec head: docs +340, form +363, menu +3,531, table +1,794, popover +3,514):onOutsidePressis optional; the menu page grows 332 B and the Popover page 360 B. That is over INV10's 0.3 KB allowance and inside the 0.4 KB that AST-116 FR24 allowsonOutsidePress: an engineering owner decided the three composition inputs load withusePopover(AST-116 DEC-9), and INV10 names the exception. A deferred load of the watch did not help: the size check counted the mode logic eagerly, and splitting moved a shared module onto the table page.