Skip to content

fix(HoverCard): Escape and focus work in the card's own document, such as an iframe - #9592

Merged
cixzhang merged 8 commits into
mainfrom
lane4/hovercard-escape-owner-document
Nov 9, 2026
Merged

cixzhang merged 8 commits into
mainfrom
lane4/hovercard-escape-owner-document

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

User impact

An app renders a HoverCard into a second document, such as a same-origin iframe or a Document Picture-in-Picture window, and the user works there:

  • Escape does nothing. The card stays up until the pointer or focus leaves, so a keyboard user can't dismiss content that covers what they're reading (WCAG 1.4.13, dismissible).
  • Tabbing from the trigger into the card closes it. Its controls can't be reached from the keyboard.

In the page itself, one thing changes: a card whose trigger sits inside a focus-trap container now takes Escape before that container, as the topmost layer. Before, the container took the press and the card stayed open.

Problem and solution fit

  • Why does it fail? The shared dismissal stack listens for Escape in each layer's own document, which it finds through getContainer. useHoverCard passed none, so the stack listened only in the page's document. The hook also looked up its card, and the focused element, in the page's document. In a second document the card is never found, so the hook reads it as closed, and focus moving into it reads as focus leaving.
  • Why does that harm the task? Escape is the keyboard's way to dismiss hover content, and focus moving into the card is how the keyboard reaches its controls.
  • Why does it matter? Apps that pop a panel out into Picture-in-Picture, or embed one in an iframe, ship hover cards there. Popover, Dialog and the layer stack already work in a second document.

Expected behavior and authority

  • component:HoverCard FR6 (current): Escape closes a visible card through the shared dismissal stack. The record lists the other-document failure as an implementation gap under Current-state impact, and AR2 cites WCAG 1.4.13.
  • family:overlay-dismissal: the stack routes a press to the top-most layer of the document it arrived in.

Smallest restoration

  • useHoverCard registers with getContainer: () => triggerRef.current, once its trigger is attached, so a trigger rendered after the hook mounts still registers in its own document. It also reads the trigger's ownerDocument (a small ownerDocumentOf helper) in the four places that read the page's document: Escape presence, the Escape focus check, the controlled-close focus check, and the focus-into-card check.
  • No new API. In the page, ranking by the trigger's place puts a card inside a focus-trap container above that container.
  • Record:
    • FR6's gap sentence becomes the behavior: the topmost layer in its trigger's document.
    • The Current-state bullet and AR2's "other-document gap" are dropped.
    • FR4–FR6's verification row names the new cases.
    • The readiness count goes from three gaps to two.
    • family:overlay-dismissal drops the Tooltip/HoverCard row's sentence that HoverCard reads the page's document, and its FR8/FR9 evidence row names HoverCard's second-document checks.

Evidence

  • Reproduction before the change: the five new jsdom cases in HoverCard.test.tsx fail on main:
    • in a second document (a real iframe document): Escape there doesn't close the card; focus doesn't return to the trigger; focus moving into the card closes it; a useHoverCard trigger rendered there after the hook mounts leaves Escape in that document doing nothing (this one also fails at the previous head of this PR);
    • in the page: a card whose trigger sits inside a useFocusTrap container loses Escape to the container.
  • Result after the change: all five pass; the HoverCard suite passes (87 tests).
  • Representative unchanged path: the existing HoverCard suite (page Escape, refocus, hold) and useLayerDismissal.test.tsx pass unchanged (93 tests).
  • Regression test or other mutation-sensitive proof:
    • Reverting only the focus-into-card read fails that case alone, and reverting the hook fails all three.
    • HoverCardSecondDocument.a11y.chromium.spec.ts drives a new no-visual story in Chromium, in a same-origin iframe and in a Document Picture-in-Picture window (Pop out): Escape pressed there closes the card, and Escape from inside the card returns focus to the trigger.

Scope

  • One defect is restored: the card works in its own document.
  • Separable contradictory or unsettled tagalongs were removed or split. The other HoverCard gaps (replaced trigger, roving focus trigger, mixed text children, focus hold, held-closed) are separate PRs.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run packages/core/src/HoverCard packages/core/src/Layer/useLayerDismissal.test.tsx: 93 passed.
  • pnpm check:knowledge: aligned.
  • The Chromium spec runs in CI's scoped a11y leg.

Writing rubric results

Run over the FR6 row, AR2, Current-state impact, the FR4–FR6 verification row, and family:overlay-dismissal's Tooltip/HoverCard and FR8/FR9 rows (docs/contributing/spec-writing.md):

  • Present tense, describes the system: yes. The removed gap text is gone, not reworded as history.
  • One owner per fact: HoverCard owns where its Escape applies, and the stack's per-document routing stays in family:overlay-dismissal.
  • Testable: FR6 names an observable outcome (Escape in the card's document closes it, a layer beneath stays open), and the verification row names the cases.
  • Plain language: short sentences, active voice.

component:HoverCard FR6: Escape closes a visible card through the shared
dismissal stack. The stack listens in each layer's own document, found
through getContainer, but useHoverCard passed none and read the page's
document for presence, the focus check, and the focus-into-card check. A
card rendered into an iframe or a Picture-in-Picture window therefore never
closed on Escape there (WCAG 1.4.13), and focus moving into it closed it.

useHoverCard now registers with getContainer: () => triggerRef.current and
reads the trigger's ownerDocument wherever it read the page's. Tests: three
jsdom cases in a real second document (red before), a Chromium spec over a
new no-visual iframe story. Record: FR6 loses its gap sentence, AR2 and
Current-state impact drop the other-document gap, and the verification row
names the cases.
@vercel

vercel Bot commented Nov 2, 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 9, 2026 4:48am UTC

Request Review

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

astracat-bot Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 9, 2026, 4:59 AM UTC

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 2026
@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec cf5ab9d

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 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.

Changes requested: the hook change itself works (the three new iframe cases fail on main and pass here), but a record fix and a wording or test fix are needed first.

  • docs/families/overlay-dismissal.md still ends the Tooltip/HoverCard member row with "HoverCard reads its presence from the page's document, so in another document it takes no request (FR8) and returns no focus there (FR9)"; please drop that sentence so it does not contradict the updated FR6.
  • The changeset and FR6 name Picture-in-Picture windows, but every new case runs in a same-origin iframe; add a Picture-in-Picture case to HoverCardSecondDocument.a11y.chromium.spec.ts (the Popover second-document spec already has the harness) or narrow the wording to iframes.

Optional: move ownerDocumentOf so the "Focus trigger behavior" doc comment stays on HoverCardFocusTrigger.

[Automated review]

Comment thread .changeset/hovercard-second-document.md Resolved
@github-actions

github-actions Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · f76cf39

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
LayerProvider 4.2 kB (0) · 20 B CSS (0) — ✓ · ✓ · ✗
lab/CommentComposer 151.7 kB (+128 B) · 1.9 kB CSS (0) — — · — · —
charts/ChartTooltip 181.1 kB (+115 B) · 423 B CSS (0) — — · — · —
116 more components
Component Size LoC Visual · A11y · RTL
ChatComposer 78.4 kB (+105 B) · 12.0 kB CSS (0) — — · — · —
charts/Chart 203.7 kB (+91 B) · 494 B CSS (0) — — · — · —
lab/CommentThread 344.0 kB (+90 B) · 2.4 kB CSS (0) — — · — · —
lab/Comments 350.8 kB (+78 B) · 2.5 kB CSS (0) — — · — · —
ChatComposerInput 76.0 kB (+75 B) · 11.3 kB CSS (0) — — · — · —
ChatComposerTokenElement 76.0 kB (+75 B) · 11.3 kB CSS (0) — — · — · —
HoverCard · Storybook 28.0 kB (+53 B) · 4.4 kB CSS (0) 837 (+11) ✓ · ✓ · —
Tokenizer 91.5 kB (+27 B) · 18.8 kB CSS (0) — — · — · —
DropdownMenu 97.3 kB (+26 B) · 17.6 kB CSS (0) — — · — · —
MoreMenu 97.5 kB (+25 B) · 17.6 kB CSS (0) — — · — · —
lab/TourStep 97.4 kB (+24 B) · 590 B CSS (0) — — · — · —
lab/Schedule 106.2 kB (+23 B) · 3.9 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 278.1 kB (+23 B) · 454 B CSS (0) — — · — · —
Popover 91.1 kB (+21 B) · 14.2 kB CSS (0) — — · — · —
BottomSheet 68.2 kB (+20 B) · 7.7 kB CSS (0) — — · — · —
ContextMenu 108.4 kB (+20 B) · 17.4 kB CSS (0) — — · — · —
TableCell 109.6 kB (+20 B) · 17.9 kB CSS (0) — — · — · —
Avatar 43.3 kB (+18 B) · 5.5 kB CSS (0) — — · — · —
MultiSelector 94.9 kB (+18 B) · 16.8 kB CSS (0) — — · — · —
PowerSearch 287.0 kB (+17 B) · 24.1 kB CSS (0) — — · — · —
lab/CommentPin 57.3 kB (+16 B) · 1.2 kB CSS (0) — — · — · —
Dialog 23.9 kB (+15 B) · 6.9 kB CSS (0) — — · — · —
SegmentedControl 96.2 kB (+15 B) · 6.9 kB CSS (0) — — · — · —
lab/TransferListSelector 109.1 kB (+15 B) · 1.4 kB CSS (0) — — · — · —
Slider 109.3 kB (+14 B) · 8.8 kB CSS (0) — — · — · —
TableHeaderCell 109.2 kB (+14 B) · 17.7 kB CSS (0) — — · — · —
AvatarGroup 46.1 kB (+13 B) · 5.7 kB CSS (0) — — · — · —
AvatarGroupOverflow 49.0 kB (+13 B) · 5.6 kB CSS (0) — — · — · —
DateTimeInput 208.4 kB (+13 B) · 18.7 kB CSS (0) — — · — · —
ToggleButton 86.8 kB (+13 B) · 10.1 kB CSS (0) — — · — · —
FileInput 69.3 kB (+12 B) · 10.9 kB CSS (0) — — · — · —
Typeahead 79.8 kB (+12 B) · 12.4 kB CSS (0) — — · — · —
DropdownMenuSubMenu 70.4 kB (+11 B) · 9.7 kB CSS (0) — — · — · —
lab/DialogHeroHeader 83.4 kB (+11 B) · 372 B CSS (0) — — · — · —
RadioList 56.5 kB (+10 B) · 7.3 kB CSS (0) — — · — · —
SideNavItem 70.6 kB (+10 B) · 11.1 kB CSS (0) — — · — · —
Table 124.9 kB (+10 B) · 18.3 kB CSS (0) — — · — · —
lab/EmojiPicker 86.9 kB (+10 B) · 751 B CSS (0) — — · — · —
Field 55.1 kB (+9 B) · 7.2 kB CSS (0) — — · — · —
MobileNav 70.7 kB (+9 B) · 10.6 kB CSS (0) — — · — · —
NumberInput 71.9 kB (+9 B) · 11.4 kB CSS (0) — — · — · —
StatusDot 31.4 kB (+9 B) · 5.3 kB CSS (0) — — · — · —
Tooltip 29.7 kB (+9 B) · 4.4 kB CSS (0) — — · — · —
lab/SelectableCardGroup 64.6 kB (+9 B) · 162 B CSS (0) — — · — · —
Carousel 70.0 kB (+8 B) · 10.9 kB CSS (0) — — · — · —
CommandPalette 73.3 kB (+8 B) · 12.7 kB CSS (0) — — · — · —
ComplexSelector 71.1 kB (+8 B) · 11.8 kB CSS (0) — — · — · —
FieldLabel 51.2 kB (+8 B) · 5.7 kB CSS (0) — — · — · —
lab/ListInput 88.3 kB (+8 B) · 922 B CSS (0) — — · — · —
richtext/RichTextEditor 297.4 kB (+8 B) · 2.6 kB CSS (0) — — · — · —
richtext/RichTextView 276.4 kB (+8 B) · 2.3 kB CSS (0) — — · — · —
AppShell 91.0 kB (+7 B) · 13.5 kB CSS (0) — — · — · —
BottomSheetSwitcher 17.9 kB (+7 B) · 3.4 kB CSS (0) — — · — · —
ChatLayout 83.0 kB (+7 B) · 10.5 kB CSS (0) — — · — · —
CheckboxList 68.0 kB (+7 B) · 7.7 kB CSS (0) — — · — · —
InfoTip 46.8 kB (+7 B) · 5.3 kB CSS (0) — — · — · —
TextArea 62.6 kB (+7 B) · 9.3 kB CSS (0) — — · — · —
TextInput 67.9 kB (+7 B) · 11.2 kB CSS (0) — — · — · —
Thumbnail 64.8 kB (+7 B) · 11.6 kB CSS (0) — — · — · —
lab/DiffViewer 87.4 kB (+7 B) · 2.1 kB CSS (0) — — · — · —
lab/TransferList 101.6 kB (+7 B) · 1.2 kB CSS (0) — — · — · —
AlertDialog 105.5 kB (+6 B) · 14.6 kB CSS (0) — — · — · —
InputGroup 56.7 kB (+6 B) · 7.8 kB CSS (0) — — · — · —
Link 53.2 kB (+6 B) · 7.0 kB CSS (0) — — · — · —
ListItem 70.4 kB (+6 B) · 11.4 kB CSS (0) — — · — · —
Pagination 110.0 kB (+6 B) · 17.8 kB CSS (0) — — · — · —
SideNav 114.2 kB (+6 B) · 11.4 kB CSS (0) — — · — · —
SideNavHeading 75.7 kB (+5 B) · 11.3 kB CSS (0) — — · — · —
Switch 103.9 kB (+5 B) · 9.9 kB CSS (0) — — · — · —
TopNav 72.4 kB (+5 B) · 10.9 kB CSS (0) — — · — · —
TopNavHeading 75.3 kB (+5 B) · 11.2 kB CSS (0) — — · — · —
BreadcrumbItem 84.8 kB (+4 B) · 12.1 kB CSS (0) — — · — · —
CheckboxInput 64.4 kB (+4 B) · 9.2 kB CSS (0) — — · — · —
Markdown 187.6 kB (+4 B) · 20.6 kB CSS (0) — — · — · —
RadioListItem 67.6 kB (+4 B) · 10.1 kB CSS (0) — — · — · —
Selector 99.9 kB (+4 B) · 17.4 kB CSS (0) — — · — · —
TimeInput 162.2 kB (+4 B) · 16.0 kB CSS (0) — — · — · —
BaseTypeahead 71.2 kB (+3 B) · 10.9 kB CSS (0) — — · — · —
Button 60.4 kB (+3 B) · 10.0 kB CSS (0) — — · — · —
TabMenu 71.9 kB (+3 B) · 11.1 kB CSS (0) — — · — · —
DateInput 186.7 kB (+2 B) · 17.0 kB CSS (0) — — · — · —
Lightbox 122.6 kB (+2 B) · 10.6 kB CSS (0) — — · — · —
Timer 14.0 kB (+2 B) · 6.0 kB CSS (0) — — · — · —
Calendar 71.4 kB (+1 B) · 10.6 kB CSS (0) — — · — · —
ChatDictationButton 61.0 kB (+1 B) · 10.0 kB CSS (0) — — · — · —
CodeBlock 75.4 kB (+1 B) · 11.3 kB CSS (0) — — · — · —
CommandPaletteInput 31.7 kB (+1 B) · 7.5 kB CSS (0) — — · — · —
DrawerHeader 63.4 kB (+1 B) · 12.9 kB CSS (0) — — · — · —
MobileNavToggle 60.7 kB (+1 B) · 10.0 kB CSS (0) — — · — · —
TopNavMenu 74.7 kB (+1 B) · 11.2 kB CSS (0) — — · — · —
charts/ChartLegend 49.5 kB (0) · 224 B CSS (0) — — · — · —
Banner 62.4 kB (0) · 10.5 kB CSS (0) — — · — · —
ChatLayoutScrollButton 60.9 kB (0) · 10.2 kB CSS (0) — — · — · —
ChatMessageList 28.1 kB (0) · 7.0 kB CSS (0) — — · — · —
ChatSendButton 60.8 kB (0) · 10.0 kB CSS (0) — — · — · —
ChatToolCalls 32.0 kB (0) · 8.3 kB CSS (0) — — · — · —
DateRangeInput 92.8 kB (0) · 12.5 kB CSS (0) — — · — · —
DialogHeader 63.2 kB (0) · 11.5 kB CSS (0) — — · — · —
Heading 12.4 kB (0) · 5.4 kB CSS (0) — — · — · —
IconButton 60.5 kB (0) · 10.0 kB CSS (0) — — · — · —
ProgressBar 11.7 kB (0) · 6.3 kB CSS (0) — — · — · —
Spinner 24.7 kB (0) · 6.2 kB CSS (0) — — · — · —
Stepper 62.0 kB (0) · 10.1 kB CSS (0) — — · — · —
TableSelectionToolbar 70.7 kB (0) · 13.2 kB CSS (0) — — · — · —
Text 11.8 kB (0) · 5.4 kB CSS (0) — — · — · —
Timestamp 33.2 kB (0) · 10.2 kB CSS (0) — — · — · —
lab/ChatReactionBar 107.1 kB (0) · 1.1 kB CSS (0) — — · — · —
CheckboxListItem 71.4 kB (−1 B) · 11.4 kB CSS (0) — — · — · —
SideNavCollapseButton 61.2 kB (−1 B) · 10.0 kB CSS (0) — — · — · —
lab/LineClamp 14.0 kB (−1 B) · 168 B CSS (0) — — · — · —
Drawer 50.7 kB (−3 B) · 8.3 kB CSS (0) — — · — · —
Toast 98.3 kB (−5 B) · 10.3 kB CSS (0) — — · — · —
TopNavMegaMenu 69.9 kB (−8 B) · 11.8 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 105.9 kB (−9 B) · 773 B CSS (0) — — · — · —
layer — — — · ✓ · —
Layer — — ✓ · ✓ · —

Package size: @astryxdesign/core 7.20 MB packed (+797 B); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 34 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

…ent; add the Picture-in-Picture case

CodeBunny on #9592: the family record's Tooltip/HoverCard row still said
HoverCard reads its presence from the page's document; that sentence goes,
and the FR8/FR9 evidence row names HoverCard's second-document checks. The
story gains a Pop out button that portals the card into a Document
Picture-in-Picture window, and the Chromium spec checks Escape and the focus
return there too, so the changeset's Picture-in-Picture claim has a test.
The ownerDocumentOf helper moves above HoverCardFocusTrigger's doc comment,
and the readiness count drops to seven gaps.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 2026
@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec b3b8e9f

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 2, 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.

Changes requested: the hook fix works in both an iframe and a Picture-in-Picture window, but the new Picture-in-Picture Chromium case cannot pass as written.

  • In HoverCardSecondDocument.a11y.chromium.spec.ts, the second trigger.hover() (line 97) lands where the pointer already rests, so no mouseenter fires and line 98 times out; adding await pictureInPicture.mouse.move(0, 0); before it makes all three cases pass.

Optional: the change also lets a card whose trigger sits inside a raw useFocusTrap container take Escape before that trap in the page, which deserves a line in the changeset, and ownerDocumentOf's comment can keep only its reason.

[Automated review]

…e hovering it again

CodeBunny on #9592: the second hover landed where the pointer already
rested, so no mouseenter fired; the case moves the pointer away first. The
changeset notes that a card inside a focus-trap container now takes Escape
before it, and ownerDocumentOf's comment keeps only its reason.
@cixzhang

cixzhang commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec e53260c

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

Changes requested: the second-document fix works in an iframe and a Picture-in-Picture window (the new jsdom cases fail on main and pass here, and all three Chromium cases pass), but two things need fixing first.

  • A useHoverCard trigger rendered after the hook mounts, inside a second document, leaves the card registered in the page, so Escape pressed in the page closes that card and Escape in its own document does nothing; register once the trigger exists, in its document, and add a case for it.
  • The changeset says a card inside a focus-trap container now takes Escape first, but no test covers it and the description still says nothing changes in the page, so add a case and update the description.

[Automated review]

@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 8, 2026
…ard-escape-owner-document

# Conflicts:
#	docs/families/overlay-dismissal.md
#	docs/specs/components/HoverCard/HoverCard.spec.md
#	packages/core/src/HoverCard/HoverCard.test.tsx
#	packages/core/src/HoverCard/useHoverCard.tsx
…ttaches

The dismissal stack listens in the document a layer registers with. A
useHoverCard trigger rendered after the hook mounts used to leave the
card registered in the page, so Escape in its own document did nothing.
The card now registers once its trigger is attached. New cases cover
that and a trigger inside a focus-trap container taking Escape first.
@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Nov 9, 2026
@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 5451bcd

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 9, 2026
@cixzhang
cixzhang marked this pull request as ready for review November 9, 2026 03:44

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

Changes requested: the second-document fix now registers a trigger attached after mount in its own document, and the focus-trap ranking is tested and described, but three things need fixing first.

  • A useHoverCard trigger that moves between documents while the hook stays mounted keeps its first registration, so Escape pressed in the page closes a card in the frame and, after a move back, Escape in the page no longer closes it; re-register whenever the trigger attaches in a different document, in the shared dismissal owner, and add a case that moves one trigger into the frame and back.
  • The trigger's Document is kept in React state (useHoverCard.tsx:316), which the React runtime rules forbid for DOM nodes, so drop it with the fix above or gate registration on a boolean instead (this corrects my earlier suggestion to hold the document in state).
  • Regression: since the latest merge of main, lint rejects the @playwright/test import in HoverCardSecondDocument.a11y.chromium.spec.ts and CI's lint job fails on it, so import expect, test and type Page from @astryxdesign/a11y-spec/playwright, as the Popover second-document spec does.

[Automated review]

@cixzhang
cixzhang marked this pull request as draft November 9, 2026 04:09
…ocument

A trigger that moves between documents kept the card's first
registration, so Escape reached the wrong document. useHoverCard now
counts the trigger's documents in a key, and an internal keyed form of
useLayerDismissal registers again when the key changes. The document
itself is no longer held in React state. The second-document browser
spec imports Playwright through the a11y-spec wrapper.
@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec 0169d99

@cixzhang
cixzhang marked this pull request as ready for review November 9, 2026 04:14

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: the test check is still running on this head; every other check has passed.

The last review's three blockers are fixed: a useHoverCard trigger that moves between documents now registers again where it lands, the trigger's document stays out of React state, and the Chromium spec imports through the a11y-spec wrapper. Every new case fails on main and passes here, and the Chromium spec passes on this head's Storybook build.

Optional, non-blocking:

  • Two comments in useHoverCard.tsx can be shorter and more exact; see the inline suggestions.
  • Name HoverCardSecondDocument.a11y.chromium.spec.ts in the HoverCard and overlay-dismissal verification rows, as the Popover row names its spec.
  • The description still counts five new cases and 87 tests; the head has six and 88.

[Automated review]

Comment on lines +314 to +316
// The dismissal stack listens in the document a layer registers with, so
// the card registers when its trigger attaches, and again when the trigger
// attaches in another document. The key counts those documents.

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 runs to 28 words, and the key does not count documents: it changes on every move, so page, frame, page reaches three. Shorter:

// The stack listens in the document the card registers with. The key changes
// each time the trigger attaches in a different document, so the card
// registers there again.

Comment on lines +504 to +507
// Registered from the trigger's attach for the hook's lifetime, in the
// trigger's document, rather than gated on `layer.isOpen`:
// that state can lag a frame behind the DOM, so a press arriving right after
// the layer appears would find nothing registered. Because this layer

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: this still opens with a 40-word sentence. Shorter:

// Registered once the trigger attaches, in its document. Not gated on
// `layer.isOpen`: that state can lag a frame behind the DOM, so a press right
// after the layer appears would find nothing registered.

…ard-escape-owner-document

# Conflicts:
#	docs/specs/components/HoverCard/HoverCard.spec.md
@cixzhang
cixzhang marked this pull request as draft November 9, 2026 04:41
@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

/approve-spec f76cf39

@cixzhang
cixzhang marked this pull request as ready for review November 9, 2026 04:42

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved pending CI: one unit test shard, test-ui (4/4), is still running on this head; every other check has passed.

Merging main keeps the second-document fix intact: the six new cases still fail on main and pass here, and the Chromium spec passes in an iframe and in a Picture-in-Picture window on this head's Storybook build.

Optional, non-blocking:

  • The two earlier inline suggestions on comments in useHoverCard.tsx still apply.
  • Add a case for a controlled close with focus inside a card in a second document (useHoverCard.tsx:652-654).
  • Name HoverCardSecondDocument.a11y.chromium.spec.ts in the HoverCard and overlay-dismissal verification rows, as the Popover row names its spec.
  • The description still counts five new cases and 87 HoverCard tests; the head has six and 89.

[Automated review]

@cixzhang
cixzhang merged commit b01b7ee into main Nov 9, 2026
130 checks passed
@github-actions
github-actions Bot deleted the lane4/hovercard-escape-owner-document branch November 9, 2026 06:03

This branch was successfully deployed

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

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) 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