Skip to content

feat(usePopover): onOutsidePress can keep a popover open (AST-116 FR9–FR11) - #11132

Draft
nynexman4464 wants to merge 1 commit into
nynexman4464/feat/popover-anchor-out-of-viewfrom
nynexman4464/feat/popover-outside-press
Draft

nynexman4464 wants to merge 1 commit into
nynexman4464/feat/popover-anchor-out-of-viewfrom
nynexman4464/feat/popover-outside-press

Conversation

@nynexman4464

@nynexman4464 nynexman4464 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Status: The spec this stack implements (#11112) is being revised after owner review: anchor becomes anchorRef (a ref only), hiding while the anchor is out of view becomes built-in layer behavior with no option, and onOutsidePress is not implemented. This PR will be replaced by the rule that a show() in the same press moves the popover, with no callback, once the spec PR is updated. This head only carries a rebase. The first-load size exception described below goes away with the rework.

Stacked on #11122 (the AST-116 stack; its spec, #11112, is proposed and not on main yet, and an engineering owner approved its head, including the follow-ups).

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's onOutsidePress(event) (AST-116 FR9–FR11, DEC-4, DEC-8):

  • It is called for each press that starts and ends outside the open popover, before the popover closes for it.
  • event.preventDefault() keeps the popover open.
  • The event is the popover's own (target, pointerType) and carries no browser event, so cancelling never cancels the press: its focus change and click reach the page unchanged.
  • A press on a separate anchor is outside. A press on the trigger keeps its released toggle and is not reported.
  • With hasLightDismiss: false it is never called. Escape and the fallback close are not outside presses.

Current specification

spec:AST-116 FR9–FR11, DEC-4, DEC-8 (proposed in #11112; not on main yet).

Public delta and caller burden

  • New optional onOutsidePress?: (event: PopoverOutsidePressEvent) => void on UsePopoverOptions; new exported type PopoverOutsidePressEvent. PopoverProps is unchanged.
  • With no callback, nothing changes: the layer stays popover="auto" (asserted).
  • With a callback, the layer is 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.
  • Internal: watchOutsidePress hands its onOutside the ending event, and a false return means the layer stayed open. Such a press is not counted as an outside dismissal, so a modal host's backdrop handler (family:overlay-dismissal FR11) does not mistake a vetoed press for a closed layer.
usePopover({
  anchor: () => pencilFor(rowId),
  onOutsidePress: event => {
    if (event.target?.closest('[data-row-edit]')) event.preventDefault();
  },
  ...
});

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):
    • reported and closes;
    • cancelled stays open, the press itself is not cancelled, and the event carries no browser event;
    • press on the anchor is outside;
    • presses inside and on the trigger are not reported;
    • hasLightDismiss: false never calls it;
    • Escape is not an outside press;
    • native auto without a callback, manual with one.
  • outsidePress.test.ts: a declined press is handed the ending event and not counted.
  • Real browser, Chromium, Firefox and WebKit, run against the earlier <Popover onOutsidePress> shape (the same hook path; not re-run since the move to usePopover only) (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.

Chromium: popover moved to row 4 after a vetoed press

Scope

Components: usePopover, Layer outside-press watch (internal)

  • 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

Changes since the last review

  • Light dismiss turned off while the popover is open now stops the watch: the next outside press neither calls onOutsidePress nor closes the popover. hasLightDismiss is read at press time. Test: "stops reporting and closing when light dismiss turns off while open" (fails without the change).
  • First-load size: AST-116 FR24 and DEC-9 now keep this input in usePopover at 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):

docs form menu table popover
+0 +0 +332 +0 +360

onOutsidePress is 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 allows onOutsidePress: an engineering owner decided the three composition inputs load with usePopover (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.

@vercel

vercel Bot commented Nov 11, 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 18, 2026 10:15pm UTC

Request Review

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

astracat-bot Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 18, 2026, 10:26 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 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 onOutsidePress is set while the popover is open flips the layer between popover="manual" and popover="auto", which closes it and reports onOpenChange(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 of useOutsidePress, so start it in handleLayerShow, stop it in onHide, and delete the Effect.

Automated review (maintainer link)

@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-outside-press branch from 5fc7a19 to b19b6a1 Compare November 11, 2026 15:43
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor-out-of-view branch from 3cf6201 to e91b0ff Compare November 11, 2026 15:43
@nynexman4464 nynexman4464 changed the title feat(Popover): onOutsidePress can keep a popover open (AST-113 FR9–FR11) feat(Popover): onOutsidePress can keep a popover open (AST-116 FR9–FR11) 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 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 onOutsidePress while the popover is open flips the layer between popover="manual" and popover="auto", which closes it and reports onOpenChange(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 of useOutsidePress, so start it in handleLayerShow, stop it in a wrapped onHide, and delete the Effect.

Automated review (maintainer link)

@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor-out-of-view branch from e91b0ff to e18f427 Compare November 16, 2026 22:36
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-outside-press branch from b19b6a1 to d219845 Compare November 16, 2026 22:36
@nynexman4464 nynexman4464 changed the title feat(Popover): onOutsidePress can keep a popover open (AST-116 FR9–FR11) feat(usePopover): onOutsidePress can keep a popover open (AST-116 FR9–FR11) 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 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 onOutsidePress while the popover is open flips the layer between popover="manual" and popover="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 in handleLayerShow, stop it in a wrapped onHide, and delete the Effect.
  • Newly live check: onOutsidePressRef.current and hideRef.current are written during render (usePopover.tsx:716-719), so keep both through useCommittedRef, which is on main.
  • Newly live check: the veto code adds first-load JavaScript to every page that renders Popover, usePopover or 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 on main), over the 0.3 KB an optional feature may cost, so load it only when a caller passes onOutsidePress and 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: usePopover accepts onOutsidePress: 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 PopoverProps unchanged: verified (generated API delta; Popover.tsx untouched).
  • 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 return false).
  • 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).

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 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 onOutsidePress while the popover is open closes it, because the layer's popover attribute 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), against architecture:react-component-runtime INV2 and INV3; start it in handleLayerShow and stop it in a wrapped onHide, as useOutsidePress documents and BaseTypeahead and Selector do.
  • A page that renders Popover without onOutsidePress grows 328 B gzip of first-load JavaScript (a DropdownMenu page 327 B), over the 307 B that architecture:component-import-boundaries INV10 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 the FR9 gap line this pull request deletes; update them to describe the manual watch for an onOutsidePress caller.

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).

Automated review (maintainer link)

@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor-out-of-view branch from 370ea23 to 73ea344 Compare November 18, 2026 08:49
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-outside-press branch from 7e1a86d to 6b78b17 Compare November 18, 2026 08:49

@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 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.mjs and 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 Popover without onOutsidePress grows 328 B gzip and the menu reference page 332 B, over the 307 B that architecture:component-import-boundaries INV10 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).

Automated review (maintainer link)

| 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). |

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: "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)."

@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor-out-of-view branch from 73ea344 to 32ef02e Compare November 18, 2026 14:17
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-outside-press branch from 6b78b17 to 6e209c9 Compare November 18, 2026 14:17

@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 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 hasLightDismiss turns false while the popover is open, the watch started at open keeps running, so the next outside press still calls onOutsidePress and closes the popover, although the JSDoc and usePopover.doc.mjs say it is not called with light dismiss off (usePopover.tsx:796-836); read hasLightDismiss in 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 Popover without onOutsidePress grows 314 B gzip and the menu reference page 329 B, over the 307 B that architecture:component-import-boundaries INV10 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).

Automated review (maintainer link)

@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor-out-of-view branch from 32ef02e to 25310be Compare November 18, 2026 20:22
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-outside-press branch from 6e209c9 to fbe01d5 Compare November 18, 2026 20:22

@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 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 Popover without onOutsidePress grows 360 B gzip of first-load JavaScript and the menu reference page 332 B, over the 307 B that architecture:component-import-boundaries INV10 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.

Automated review (maintainer link)

// 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

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: 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."

@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-anchor-out-of-view branch from 25310be to 48a1e5f Compare November 18, 2026 22:01
@nynexman4464
nynexman4464 force-pushed the nynexman4464/feat/popover-outside-press branch from fbe01d5 to e93da3d Compare November 18, 2026 22:01

@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 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 Popover without onOutsidePress grows 360 B gzip of first-load JavaScript and the menu reference page 331 B, over the 307 B that architecture:component-import-boundaries INV10 on main allows (usePopover.tsx:35); this clears if the stack's INV10 exception for onOutsidePress lands on main first, 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 usePopover at its measured cost and names an INV10 exception, decided by an engineering owner: verified in the stack's approved spec; not on main.
  • 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.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — e93da3d5 Deployed Nov 18, 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