Repository navigation
fix(Dialog, Drawer): a backdrop press that closes a popover inside closes only the popover - #9988
Conversation
… inside closes only the popover (red)
…inside closes only the popover useBackdropPress notes, at pointer-down on the backdrop, the popovers that show above the host. When the click comes and one of them no longer shows, the press was that popover's light dismissal, so the host stays open; the next backdrop press closes it, as a second Escape does. Dialog, Drawer and CommandPalette share the rule. family:overlay-dismissal FR11 states it. Fixes #9920.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 56411b2 |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| charts/ChartTooltip | 142.6 kB (+251 B) · 423 B CSS (0) | — | — · — · — |
| lab/Comments | 269.9 kB (+217 B) · 2.5 kB CSS (0) | — | — · — · — |
| charts/Chart | 165.4 kB (+212 B) · 494 B CSS (0) | — | — · — · — |
111 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| lab/CommentThread | 264.6 kB (+204 B) · 2.4 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 233.1 kB (+195 B) · 454 B CSS (0) | — | — · — · — |
| CommandPalette | 58.4 kB (+188 B) · 12.3 kB CSS (0) | — | — · — · — |
| Drawer | 41.2 kB (+179 B) · 8.2 kB CSS (0) | — | — · — · — |
| AlertDialog | 90.1 kB (+171 B) · 13.1 kB CSS (0) | — | — · — · — |
| Dialog | 22.2 kB (+131 B) · 6.7 kB CSS (0) | — | — · — · — |
| PowerSearch | 248.9 kB (+122 B) · 22.3 kB CSS (0) | — | — · — · — |
| DateTimeInput · Storybook | 176.4 kB (+88 B) · 17.2 kB CSS (0) | 3,567 (+2) | — · — · — |
| ContextMenu · Storybook | 81.9 kB (+76 B) · 16.0 kB CSS (0) | 695 (+2) | — · — · — |
| Table | 91.3 kB (+75 B) · 16.7 kB CSS (0) | — | — · — · — |
| TableCell | 83.1 kB (+75 B) · 16.5 kB CSS (0) | — | — · — · — |
| Tokenizer | 73.9 kB (+75 B) · 17.1 kB CSS (0) | — | — · — · — |
| MultiSelector | 79.5 kB (+65 B) · 15.5 kB CSS (0) | — | — · — · — |
| Link | 44.3 kB (+63 B) · 6.8 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 86.4 kB (+63 B) · 1.9 kB CSS (0) | — | — · — · — |
| Calendar | 57.3 kB (+62 B) · 9.3 kB CSS (0) | — | — · — · — |
| Field | 41.9 kB (+61 B) · 6.3 kB CSS (0) | — | — · — · — |
| SideNavHeading | 61.6 kB (+60 B) · 10.0 kB CSS (0) | — | — · — · — |
| TopNavHeading | 61.0 kB (+60 B) · 9.8 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 73.0 kB (+59 B) · 2.1 kB CSS (0) | — | — · — · — |
| TopNavMenu | 60.9 kB (+58 B) · 9.9 kB CSS (0) | — | — · — · — |
| CheckboxList | 45.6 kB (+57 B) · 7.5 kB CSS (0) | — | — · — · — |
| RadioList | 43.3 kB (+57 B) · 6.4 kB CSS (0) | — | — · — · — |
| Banner | 48.8 kB (+56 B) · 9.2 kB CSS (0) | — | — · — · — |
| Button | 46.8 kB (+56 B) · 8.7 kB CSS (0) | — | — · — · — |
| DateRangeInput | 75.8 kB (+56 B) · 11.2 kB CSS (0) | — | — · — · — |
| TabMenu | 58.3 kB (+56 B) · 9.8 kB CSS (0) | — | — · — · — |
| Typeahead | 65.1 kB (+56 B) · 11.2 kB CSS (0) | — | — · — · — |
| SideNavItem | 56.7 kB (+55 B) · 9.8 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 56.1 kB (+55 B) · 10.6 kB CSS (0) | — | — · — · — |
| ChatLayout | 50.0 kB (+54 B) · 9.2 kB CSS (0) | — | — · — · — |
| InputGroup | 44.1 kB (+54 B) · 7.3 kB CSS (0) | — | — · — · — |
| Selector | 82.4 kB (+54 B) · 16.1 kB CSS (0) | — | — · — · — |
| lab/TransferList | 79.3 kB (+54 B) · 1.7 kB CSS (0) | — | — · — · — |
| Lightbox | 54.9 kB (+53 B) · 9.1 kB CSS (0) | — | — · — · — |
| Pagination | 92.5 kB (+53 B) · 16.4 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 82.6 kB (+53 B) · 16.2 kB CSS (0) | — | — · — · — |
| ChatSendButton | 47.2 kB (+52 B) · 8.7 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 56.4 kB (+52 B) · 11.8 kB CSS (0) | — | — · — · — |
| DrawerHeader | 49.9 kB (+51 B) · 11.6 kB CSS (0) | — | — · — · — |
| DialogHeader | 49.6 kB (+50 B) · 10.2 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 47.7 kB (+50 B) · 8.7 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 47.4 kB (+49 B) · 8.8 kB CSS (0) | — | — · — · — |
| lab/Schedule | 63.6 kB (+49 B) · 3.9 kB CSS (0) | — | — · — · — |
| AvatarGroup | 37.8 kB (+48 B) · 5.5 kB CSS (0) | — | — · — · — |
| Carousel | 52.7 kB (+46 B) · 9.5 kB CSS (0) | — | — · — · — |
| CodeBlock | 60.8 kB (+46 B) · 10.0 kB CSS (0) | — | — · — · — |
| Stepper | 48.5 kB (+46 B) · 8.9 kB CSS (0) | — | — · — · — |
| Avatar | 35.0 kB (+45 B) · 5.4 kB CSS (0) | — | — · — · — |
| RadioListItem | 56.0 kB (+45 B) · 9.5 kB CSS (0) | — | — · — · — |
| lab/ListInput | 85.1 kB (+45 B) · 1.6 kB CSS (0) | — | — · — · — |
| InfoTip | 37.8 kB (+44 B) · 5.0 kB CSS (0) | — | — · — · — |
| Markdown | 152.3 kB (+44 B) · 18.9 kB CSS (0) | — | — · — · — |
| MobileNavToggle | 47.2 kB (+44 B) · 8.7 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 69.4 kB (+44 B) · 1.1 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 71.1 kB (+43 B) · 11.2 kB CSS (0) | — | — · — · — |
| ComplexSelector | 57.6 kB (+43 B) · 10.4 kB CSS (0) | — | — · — · — |
| TimeInput | 140.1 kB (+43 B) · 14.5 kB CSS (0) | — | — · — · — |
| ToggleButton | 47.7 kB (+43 B) · 8.8 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 52.0 kB (+43 B) · 162 B CSS (0) | — | — · — · — |
| lab/TourStep | 61.1 kB (+43 B) · 590 B CSS (0) | — | — · — · — |
| AppShell | 75.2 kB (+42 B) · 12.2 kB CSS (0) | — | — · — · — |
| ListItem | 57.7 kB (+42 B) · 10.5 kB CSS (0) | — | — · — · — |
| TextInput | 54.6 kB (+42 B) · 9.9 kB CSS (0) | — | — · — · — |
| Tooltip · Storybook | 20.9 kB (+42 B) · 3.9 kB CSS (0) | 819 (+2) | — · — · — |
| lab/ChatEmojiPicker | 68.9 kB (+42 B) · 773 B CSS (0) | — | — · — · — |
| Popover | 55.2 kB (+41 B) · 12.7 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 47.3 kB (+40 B) · 8.9 kB CSS (0) | — | — · — · — |
| CheckboxInput | 53.1 kB (+40 B) · 8.8 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 58.4 kB (+40 B) · 10.5 kB CSS (0) | — | — · — · — |
| DropdownMenu | 77.4 kB (+40 B) · 16.1 kB CSS (0) | — | — · — · — |
| IconButton | 46.8 kB (+40 B) · 8.7 kB CSS (0) | — | — · — · — |
| StatusDot | 23.1 kB (+40 B) · 5.2 kB CSS (0) | — | — · — · — |
| Toast | 60.6 kB (+40 B) · 9.0 kB CSS (0) | — | — · — · — |
| SegmentedControl | 83.8 kB (+39 B) · 6.7 kB CSS (0) | — | — · — · — |
| FileInput | 55.4 kB (+37 B) · 9.6 kB CSS (0) | — | — · — · — |
| MobileNav | 56.7 kB (+37 B) · 9.3 kB CSS (0) | — | — · — · — |
| MoreMenu | 77.6 kB (+37 B) · 16.1 kB CSS (0) | — | — · — · — |
| Switch | 90.0 kB (+37 B) · 9.5 kB CSS (0) | — | — · — · — |
| TextArea | 49.2 kB (+37 B) · 8.8 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 48.4 kB (+37 B) · 1.2 kB CSS (0) | — | — · — · — |
| NumberInput | 57.9 kB (+36 B) · 10.1 kB CSS (0) | — | — · — · — |
| SideNav | 75.8 kB (+36 B) · 10.1 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 263.4 kB (+35 B) · 2.3 kB CSS (0) | — | — · — · — |
| Slider | 92.3 kB (+33 B) · 8.3 kB CSS (0) | — | — · — · — |
| FieldLabel | 38.0 kB (+32 B) · 4.8 kB CSS (0) | — | — · — · — |
| LayerProvider | 64.4 kB (+31 B) · 9.4 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 283.0 kB (+31 B) · 2.6 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 57.2 kB (+30 B) · 9.6 kB CSS (0) | — | — · — · — |
| Thumbnail | 51.1 kB (+29 B) · 10.2 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 72.4 kB (+29 B) · 722 B CSS (0) | — | — · — · — |
| AvatarGroupOverflow | 40.3 kB (+26 B) · 5.4 kB CSS (0) | — | — · — · — |
| HoverCard | 19.5 kB (+26 B) · 3.9 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 108.6 kB (+25 B) · 1.9 kB CSS (0) | — | — · — · — |
| TopNav | 58.3 kB (+22 B) · 9.6 kB CSS (0) | — | — · — · — |
| ChatComposer | 63.3 kB (+20 B) · 10.5 kB CSS (0) | — | — · — · — |
| DateInput · Storybook | 154.5 kB (+7 B) · 15.5 kB CSS (0) | 5,105 (+2) | — · — · — |
| charts/ChartLegend | 35.5 kB (+3 B) · 224 B CSS (0) | — | — · — · — |
| Heading | 7.9 kB (+1 B) · 4.9 kB CSS (0) | — | — · — · — |
| ProgressBar | 10.9 kB (+1 B) · 6.2 kB CSS (0) | — | — · — · — |
| Text | 7.4 kB (+1 B) · 4.9 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 61.3 kB (0) · 10.0 kB CSS (0) | — | — · — · — |
| ChatMessageList | 23.0 kB (0) · 6.8 kB CSS (0) | — | — · — · — |
| ChatToolCalls | 26.0 kB (0) · 8.2 kB CSS (0) | — | — · — · — |
| Spinner | 18.6 kB (0) · 5.7 kB CSS (0) | — | — · — · — |
| Timer | 9.6 kB (0) · 5.9 kB CSS (0) | — | — · — · — |
| TypeaheadItem | 6.4 kB (0) · 3.6 kB CSS (0) | — | — · — · — |
| CommandPaletteInput | 27.0 kB (−1 B) · 7.4 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 59.4 kB (−1 B) · 9.2 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 61.3 kB (−2 B) · 10.0 kB CSS (0) | — | — · — · — |
| Timestamp | 21.4 kB (−2 B) · 8.9 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 6.48 MB packed (+1.6 kB); no new dependencies.
API changes: none in this pull request
Committed API report behind this build: cli 9 rows, core 3 rows; run pnpm api:report.
Wide change (6 components): add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Requesting changes. A backdrop press now closes only the menu or combobox list open inside a Dialog or Drawer, and the second press closes the host, as described; two things need to change before this can land.
- Any popover that stops showing during the press now cancels the backdrop dismissal, so with keyboard focus on a button that has a Tooltip in a Dialog or Drawer (or with the pointer just off one), a backdrop press held longer than the Tooltip's 100 ms hide delay leaves the host open; count only layers this press can light-dismiss, not an unpinned Tooltip or a layer unrelated to the host (
useBackdropPress.tslines 31-36 and 90-92), and add a test where a Tooltip hides during the press. - Desktop behavior change needs an owner decision: the new rule changes what a mouse click on the backdrop does (
useBackdropPress.tslines 68-70 and 90-99), so gate it to touch input or cite the decision.
The new unit cases fail before the change and pass after it. Optional: popoversShowingAbove returns every other showing popover, so a name that says that would let the comment above it go.
[Automated review]
| function popoversShowingAbove(host: HTMLElement): ReadonlyArray<Element> { | ||
| return Array.from(host.ownerDocument.querySelectorAll('[popover]')).filter( | ||
| element => !element.contains(host) && isPopoverShowing(element), | ||
| ); |
There was a problem hiding this comment.
This collects every showing popover in the document that does not contain the host, so a popover that hides during the press for another reason cancels the dismissal. An unpinned Tooltip hides 100 ms after focus or the pointer leaves its trigger, and the backdrop mousedown moves focus off it: with a Tooltip showing, a backdrop press held about 180 ms leaves the Dialog or Drawer open, while a 40 ms press closes it. Count only layers this press can light-dismiss (skip an unpinned Tooltip and layers unrelated to the host), and add a test where a Tooltip hides during the press and the host still closes.
| layersAboveRef.current = isOnBackdrop | ||
| ? popoversShowingAbove(event.currentTarget) | ||
| : []; |
There was a problem hiding this comment.
Desktop behavior change needs an owner decision: this changes what a mouse click on the backdrop does for Dialog, Drawer and CommandPalette with default props. Gate it to touch input, or cite the decision.
| } | ||
| } | ||
|
|
||
| /** The popovers showing in the host's document, other than the host and what holds it. */ |
There was a problem hiding this comment.
Non-blocking: this comment exists to correct the name. popoversShowingAbove returns every showing popover that does not contain the host, not the layers above it. A name that says so (for example otherShowingPopovers, or one for the narrowed set) lets the comment go.
The backdrop press counted any popover that stopped showing, so a Tooltip hiding on its own delay kept the host open. It now counts a popover="auto" layer that closed, or a layer an outside-press watch closed, which watchOutsidePress and useTouchTrigger record with noteOutsideDismissal. Tests cover a Tooltip hiding during the press and the dismissal count.
|
/approve-spec 0ba0d96 |
|
/approve-spec ff60e99 |
There was a problem hiding this comment.
Requesting changes. A backdrop press now closes only a DropdownMenu or another native popover open inside a Dialog or Drawer, and the next press closes the host, but three things still need to change:
- With a mouse, a backdrop click still closes a Dialog together with a Typeahead list, DateInput calendar, pinned InfoTip or ContextMenu open inside it, because those layers close on focus loss or on their own
mousedownlistener before either check runs; record the dismissal where they close and add browser tests for each, or narrow FR11, the changeset and the description to the layers the change covers. - Miss:
component:DrawerFR6 (and FR4) still says a press that starts and ends on the scrim must close the Drawer whenpurposeisinfo, which a Drawer with a menu open no longer does; amend them in this pull request to defer tofamily:overlay-dismissalFR11. - Newly live check: this changes what a mouse or trackpad click on the backdrop does with default props, so the description needs to link the desktop before-and-after captures it describes for Dialog and Drawer, not only describe them.
The spec citation and the engineering-owner approval at this head already cover the desktop change once those captures are linked. Non-blocking: FR11 does not say where focus goes after a press that closes only the menu, and two source comments could be shortened.
[Automated review]
| const dismissedALayerAbove = | ||
| autoPopoversRef.current.some(layer => !isPopoverShowing(layer)) || | ||
| outsideDismissalCount(event.currentTarget.ownerDocument) !== | ||
| dismissalCountRef.current; |
There was a problem hiding this comment.
With a mouse, a Typeahead list, DateInput calendar, pinned InfoTip or ContextMenu inside the dialog closes during the mouse-down (blur close, held-tooltip focus-out release, or ContextMenu's own mousedown listener). By the click neither signal here has seen it, so the host still closes on the same click, against FR11's "same for a mouse, a pen, and a finger". Record the dismissal where those layers close on a pointer press, or narrow FR11 and the changeset.
| - **FR11 — The topmost surface consumes its outside press.** An outside press | ||
| that light-dismisses the topmost surface is consumed by it; a host surface | ||
| under it does not also light-dismiss on that press. A backdrop press that | ||
| closes a popover or menu open inside a Dialog with `purpose="info"`, a | ||
| Drawer with its scrim, or CommandPalette leaves the host open, and the next | ||
| backdrop press dismisses the host. The rule is the same for a mouse, a pen, | ||
| and a finger. |
There was a problem hiding this comment.
Miss: component:Drawer FR6 still says a press that starts and ends on the modal backdrop "MUST request close when purpose is info" (FR4 says the same). With a menu open, the Drawer no longer does that on the first press. Please amend FR6 (and FR4) in this pull request to defer to FR11.
| * backdrop press dismisses it, as a second Escape does. The press counts as | ||
| * the layer's when it light-dismissed a layer: a `popover="auto"` layer that | ||
| * showed at pointer-down no longer shows at the click, or an outside-press | ||
| * watch closed a layer. A layer that hides for another reason, such as a |
There was a problem hiding this comment.
Non-blocking (comment style): one 31-word sentence with two topics. Suggest: "The press is the layer's when it closes one. A popover="auto" layer that showed at pointer-down no longer shows at the click, or an outside-press watch counted a close."
| // How many layers an outside press has closed in each document. A modal | ||
| // host's backdrop press reads it: a press that closed a layer above the host | ||
| // is that layer's, so the host stays open. |
There was a problem hiding this comment.
Non-blocking (comment style): the first sentence restates outsideDismissals. Keep only the reason: "A modal host's backdrop press reads this. A press that closed a layer above the host is that layer's, so the host stays open."
… the host stays open With a mouse, a Typeahead list, a DateInput or DateTimeInput calendar or list, a pinned InfoTip and a ContextMenu close at mousedown (a field blur, a held tooltip's focus-out, ContextMenu's own listener), before the backdrop press could see it. Each now records its close with noteOutsideDismissal. FR11 names the layers, and Drawer FR4 and FR6 defer to it. A story and Chromium cases cover each layer inside a Dialog with a mouse.
|
/approve-spec 68980aa |
There was a problem hiding this comment.
Requesting changes. A backdrop press now closes only the menu, list, calendar, pinned tip or context menu open inside a Dialog or Drawer, and the next press closes the host, with a mouse and with a finger; the Drawer record now defers to FR11. One thing still needs to change:
- This changes what a mouse or trackpad click on the backdrop does with default props, so the description needs to link the desktop before-and-after captures it describes for Dialog and Drawer, not only describe them.
Non-blocking: FR11 does not say where focus goes after a press that closes only the layer, the DateTimeInput time-list path has no test, and two comments in outsidePress.ts could be shorter.
[Automated review]
| * noteOutsideDismissal and outsideDismissalCount, which count the layers an | ||
| * outside press or focus move closed in each document (the watch here, the | ||
| * touch trigger, a field's blur, ContextMenu and a held Tooltip record | ||
| * theirs); and the |
There was a problem hiding this comment.
Non-blocking (comment style): this @output entry now lists every caller in one sentence of over 50 words, and the header runs 22 lines. Suggest: "noteOutsideDismissal and outsideDismissalCount, a per-document count of layers that an outside press or focus move closed;" and leave the caller list to the code.
| // the host is that layer's, so the host stays open. | ||
| const outsideDismissals = new WeakMap<Document, number>(); | ||
|
|
||
| /** Records that an outside press in `doc` is closing a layer. */ |
There was a problem hiding this comment.
Non-blocking (comment style): three of the seven callers record a blur close, not an outside press. Suggest: "Records that a layer in doc is closing because a press or focus went outside it."
…eInput time list A press that closes only the layer leaves focus inside the host: where the closed layer returns it, or else on the host. A DateTimeInput time list whose field blurs at mousedown closes alone, and the next press closes the Dialog. Shorter outsidePress comments.
|
/approve-spec 8e83769 |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, and it runs once the pull request is marked ready for review.
A backdrop press now closes only the menu, list, calendar, pinned tip or context menu open inside a Dialog or Drawer, and the next press closes the host, with a mouse and with a finger. The family and Drawer records and the engineering-owner approval at this head cover the change, including its desktop behavior.
Non-blocking: FR11's new focus clause has no test yet, and the description's red-first count is now 5 cases, not 4.
[Automated review]
| const {surface, menu} = await openMenu(page); | ||
| await page.mouse.click(BACKDROP.x, BACKDROP.y); | ||
| await expect(menu).toBeHidden(); | ||
| await expect(surface).toBeVisible(); |
There was a problem hiding this comment.
Non-blocking: FR11 now says where focus goes after this press. An assertion here that focus stays inside surface (on the dialog itself, or where the closed layer returns it) would pin that clause; in Chromium today it lands on the <dialog> element.
…lendar Under a coarse pointer DateInput hands the date to the native picker, so the Chromium run (with touch support) found no calendar. The fixture sets nativePicker="never".
|
/approve-spec 5b7ce6c |
There was a problem hiding this comment.
Requesting changes for one test fixture; the fix and the records otherwise hold up.
- The DateInput case in
BackdropPress.a11y.chromium.spec.tsdoes not test the popover calendar this change touches: the spec runs withhasTouch: true, under which Chromium matches(pointer: coarse), so the fixture'snativePicker="never"opens the bottom-sheet calendar, the case passes onmain, and nothing covers the close atDateInput.tsx:859— settingpresentation="popover"on that DateInput (BackdropPressA11y.stories.tsx:125) makes the case fail onmainand pass here.
Non-blocking: FR11's focus clause has no assertion yet, and the description's "4 of the new cases fail on main" is now 5. CI has not run on this draft head yet.
[Automated review]
| label="Date" | ||
| value={date} | ||
| onChange={setDate} | ||
| nativePicker="never" |
There was a problem hiding this comment.
Under this spec's hasTouch: true, Chromium matches (pointer: coarse), so nativePicker="never" (adaptive-bottom-sheet) opens the bottom-sheet calendar. The backdrop click then hits the sheet's own backdrop, and the DateInput case passes on main too. presentation="popover" keeps the popover on every pointer and drops the deprecated prop:
presentation="popover"…cus clause The DateInput fixture uses presentation="popover", so the Chromium run (with touch support) opens the popover calendar this change covers, not the bottom sheet. The menu and layer cases assert that focus stays inside the host.
|
/approve-spec 75c0411 |
There was a problem hiding this comment.
Requesting changes for one record update; the fix, its tests and the owner-approved records hold up, and the DateInput fixture now tests the popover calendar.
- Miss:
docs/architecture/layer-runtime.mdstill says outside channels are independent (INV9, "Outside channels remain component-owned and uncoordinated", the outside-interaction list, and theLayer/outsidePress.tsownership line), whileoutsidePress.tsnow keeps a per-document dismissal count that seven close paths write and the Dialog and Drawer backdrop press reads, so please amend those three passages in this pull request to describe that count underfamily:overlay-dismissalFR11, and have an engineering owner approve the new head with/approve-spec <full head SHA>(the author may do so as an engineering owner).
[Automated review]
|
|
||
| // A modal host's backdrop press reads this. A press that closed a layer above | ||
| // the host is that layer's, so the host stays open. | ||
| const outsideDismissals = new WeakMap<Document, number>(); |
There was a problem hiding this comment.
Miss: docs/architecture/layer-runtime.md INV9 says outside channels stay "component-owned and uncoordinated", and its ownership list gives this module only the text-field outside-press watch. This count makes seven close paths' dismissals decide the modal backdrop press, so please amend INV9, the outside-interaction list and the outsidePress.ts ownership line in this pull request to describe it under family:overlay-dismissal FR11.
Outside channels stay component-owned. Their one shared fact is the per-document count in Layer/outsidePress.ts that a modal backdrop press reads (family:overlay-dismissal FR11); each path still closes only its own layer.
|
/approve-spec c0cdeaf |
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet, and it runs once the pull request is marked ready for review.
A backdrop press with a menu, list, calendar, pinned tip or context menu open inside a Dialog, Drawer or CommandPalette now closes only that layer, and the next press closes the host, with a mouse and with a finger. The family and Drawer records, the layer-runtime record's new shared outside-close count, and the engineering-owner approval at this head cover the change, including its desktop behavior.
[Automated review]
…en pointer types, and judge a press in a closed shadow root (#9814) * test(Layer): the outside-press watch can follow chosen pointer types, close on a pan, and judge a press inside a shadow root - A watch given pointer types ignores other pointers. - A watch that closes on a pan closes as a press that starts outside pans past the pan threshold, measured on each axis and beginning at the threshold itself, or when the browser takes the press. A second finger waits for the first. - A watch given a shadow root judges a press inside that root there, since the document sees a press in a closed root as a press on its host. * feat(Layer): the outside-press watch follows chosen pointer types, closes on a pan, and judges a press inside a shadow root watchOutsidePress and useOutsidePress take options: - pointerTypes: the pointer types the watch follows; every type when omitted. - closesOnPan: a press that starts outside also closes the layer as it begins to pan (the larger axis reaches core's pan threshold) or when the browser takes it. Only the first pointer counts. Its moves come through core's input stream. - root: the shadow root the layer renders in judges a press after the document, so a press inside a closed root stays inside. Callers that pass no options keep today's watch. * test(Layer): a closed shadow root judges a lift on its layer, and an unfollowed pointer's cancel leaves a followed press alone - A press that starts outside and lifts on a layer inside a closed shadow root keeps it open, as it does a light-DOM or open-root layer, with or without the pan close. The document sees that lift on the root's host. - A pointercancel from a pointer type the watch does not follow (a pen while it follows touch) leaves a followed press as it was, so that press's lift outside still closes the layer. * fix(Layer): a closed shadow root judges a lift inside it before its host does, and an unfollowed pointer's cancel is ignored - The document and the host see a lift inside a closed root as a lift on the host. So the root judges a lift inside it on the way down, and the host judges, on the way back up, a lift the root did not: one on the host itself. A press that starts outside and lifts on the layer keeps it open, as it does a light-DOM or open-root layer. - pointercancel follows the watch's pointer types, as its press and lift do. - The pan's start point has its own name, the onOutside JSDoc names the pan close, and the file header names the root and the pan moves. * test(Layer): the outside-press watch keeps a closed root's layer open inside other closed roots and in another window A press that starts outside and lifts on the layer must not close it when the layer's closed root sits inside another closed root, where the document sees the lift on the outer host, or when the root comes from a same-origin iframe, whose shadow roots are not this window's ShadowRoot. The shared shadowHostOf helper must find such a root's host too. * fix(Layer): the outside-press watch judges a closed root's lifts through the outermost host, in any window - shadowHostOf checks the node type, not instanceof ShadowRoot, so a shadow root from a same-origin iframe or a Picture-in-Picture window has a host and gets its root listener. - The new outermostShadowHostOf walks up to the host the document sees. The document's skip test and the host listener use it, so a lift on a layer whose closed root sits inside other closed roots is judged by the root, and a lift on the outer roots' other content by that host. - The closesOnPan JSDoc says other pointers are ignored while a press outside is followed. * test(Layer): a lift on an outer closed root's control that stops it still closes, and a new primary pointer is followed In nested closed roots, a control in the outer root whose pointerup handler stops propagation must not keep its lift from closing the layer, nor leave the watch following that press. A new primary pointer starts a new press when the followed press's lift never reached the document. * fix(Layer): every shadow root out to the document judges a lift in the capture phase, and a new primary pointer starts a new press - utils/flatTree's shadowRootsOutward lists the roots from a given root out to the document, each with its host; it replaces outermostShadowHostOf. - The document and each of those roots judge a lift in the capture phase, each skipping a lift whose path holds the host below it; the innermost root judges every lift it sees, and each host a lift on itself. So a control in an outer closed root that stops its pointerup no longer keeps the lift from closing the layer. Each root also judges a press's start. - With closesOnPan, a new primary pointer starts a new press, so a press whose lift never reached the document does not make the watch ignore every later touch. - isWithinLayer walks with shadowHostOf, and the private isShadowRoot goes. - Comments follow the comment style; the file header keeps main's text. * refactor(utils): the selection lock walks shadow roots through flatTree's helpers The selection lock's open-root walk keeps the open roots of shadowRootsOutward, and its host lookup for text under a shadow root calls shadowHostOf, so core has one shadow-root walk and one host check. Behavior is unchanged. The flat-tree header names the outside-press watch among its users, and a comment that restated a helper goes. * chore(Layer): the changeset names a closed shadow root, and the outside-press header keeps only its tags A press inside an open shadow root was already judged on its composed path, so the changeset now says the watch judges a press inside a closed shadow root, which the document sees as its host. The file header drops its prose, which said a cancelled press is forgotten: with `closesOnPan` a cancel closes the layer, and `watchOutsidePress`'s JSDoc states the rule. * test(Layer): a layer the outside-press watch closes on a pan or a cancel counts as an outside dismissal The per-document dismissal count (#9988) keeps a modal host open when the press on its backdrop closed a layer above it. A layer the watch closes as a press outside begins to pan, or when the browser takes that press, is such a dismissal too, as one it closes at a lift is. The case fails until the next commit. * fix(Layer): a layer the outside-press watch closes on a pan or a cancel counts as an outside dismissal `close`, which the pan and the cancel take, records the dismissal before it calls `onOutside`, as the lift does. So a modal host's backdrop press beneath a layer that closed that way keeps the host open. * Merge branch 'main' into uikit/c20-outside-pan-watch * Merge main into the ContextMenu long-press base branch (#8870 landed) * docs(Layer): split two long file-header sentences The headers of `outsidePress.ts` (`@output`) and `flatTree.ts` (`@position`) ran past INV29's sentence length. Each now says one thing per sentence. Comments only. * Merge commit '79cc4ac7784906b9cdc72a21a74241a8fcd666f9' into HEAD * refactor(utils): shadowHostOf uses nodeType's isShadowRoot `utils/nodeType.ts` now holds the cross-window shadow-root check, so `shadowHostOf` uses it and the flat tree has one shadow-root test. * Merge commit 'a2234c02c241cfba6f90217fa7745f3157009af3' into HEAD * Merge commit '6cbcbf846bc94f1cd23e1d053488ccf3b54a24fb' into HEAD Co-authored-by: Cindy Zhang <[email protected]>
Fixes #9920.
A backdrop press that closes a menu or popover open inside a
Dialog(purpose="info"), aDrawerwith its scrim, orCommandPalettenow closes only that menu or popover. The next backdrop press closes the dialog, as a second Escape already does.User impact
Current specification
family:overlay-dismissal's intent is "A person dismissing layered UI should affect only the topmost relevant surface", and Escape already works that way. The new FR11 states it for an outside press: "An outside press that light-dismisses the topmost surface is consumed by it; a host surface under it does not also light-dismiss on that press." This is case 2 of #8964; #9613 fixed case 1.How
useBackdropPress, which Dialog and Drawer share (CommandPalette renders Dialog), counts only a press that light-dismissed a layer:popover="auto"layer that showed at pointer-down no longer shows at the click.noteOutsideDismissal, and the backdrop press compares the per-document count from pointer-down to click. The layers that record:watchOutsidePress: Typeahead, DateInput, DateTimeInput, chat trigger lists);useTouchTrigger);What it doesn't block: a layer that hides for another reason, such as a Tooltip whose trigger lost focus or a toast on its timer, doesn't stop the host from closing. A test covers the Tooltip case.
Desktop behavior: the change applies to a mouse as well as a finger. Defect fix against overlay-dismissal's topmost-surface intent; main closing both surfaces on one press is the defect (spec ruling, recorded as FR11). Real-Chrome before and after for a desktop mouse are below.
Evidence
useBackdropPress.test.tsx, red first: 5 of the new cases fail on main (the 4 popover cases and the DateTimeInput time-list case). For Dialog and Drawer, with a mouse and with a finger: a backdrop press while a popover inside shows closes only the popover, and the next press closes the host. A press that closes no layer above still closes the host.BackdropPress.a11y.chromium.spec.ts: Dialog and Drawer with a DropdownMenu open inside, real Chromium mouse click and touch tap. The menu closes, the host stays, and the second press closes the host.BackdropPress.a11y.chromium.spec.tsgains these cases.family:overlay-dismissalFR11 names the layers.component:DrawerFR4 and FR6 defer to FR11.Writing rubric results
The rubric in
docs/contributing/spec-writing.mdwas run overfamily:overlay-dismissalFR11, its verification row and the AV4 reference;component:DrawerFR4 and FR6; andarchitecture:layer-runtime's outside-interaction section, INV9, theLayer/outsidePress.tsownership line and the INV9 verification row.