Skip to content

[Component Audit] Popover: keyboard, pointer, placement, and narrow-screen behavior is checked in a real browser - #12932

Draft
cixzhang wants to merge 3 commits into
mainfrom
night-watch-component-audit/Popover/2026-11-19
Draft

cixzhang wants to merge 3 commits into
mainfrom
night-watch-component-audit/Popover/2026-11-19

Conversation

@cixzhang

@cixzhang cixzhang commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

User impact

No behavior changes. Popover's keyboard, pointer, placement, right-to-left, narrow-screen, and forced-colors behavior is now checked in a real browser with receipts, so what the component does for keyboard and screen-reader users today is on record. The audit found no defect it could correct objectively here: the open ones are already being fixed in other open pull requests or need an owner decision, and are listed under Needs Review.

Audit result

  • Package/component: core/Popover (released in @astryxdesign/core under ./Popover)
  • Mode: Night Watch whole-component audit, rubric 1.16.6
  • Base: 75649f57fd8
  • Exact head: 745f475bc16d16b1a58b2ef0052d6a80dfbb4cfb
  • Component contract: existing component:Popover (authority: current), unchanged. No observational backfill was prepared.
  • Change: one browser audit spec. No source, story, or doc file changes.
Before After
Score 92.2 / C (1 open BLOCK caps the grade at C) 92.2 / C (unchanged: no fix in this pull request)
Distinct defects 1 BLOCK, 2 FIX, 0 NIT 1 BLOCK, 2 FIX, 0 NIT

Sensitivity: fix the open BLOCK and change nothing else, and the score projects to 97.0 / A (§1 keeps one FIX).

Section W Score State
§1 Accessibility 16 3 scored; the open surface is a dialog with aria-modal="true" and the caller's label; the trigger carries aria-expanded, aria-haspopup="dialog", and aria-controls naming the layer that holds the dialog (spec:AST-116 FR20 step 2 allows it); keyboard entry focuses the first switch and draws the focus ring, pointer entry focuses it with no ring; Tab cycles the switches and the fallback close control and stays inside; Escape closes and returns focus to the trigger after a keyboard open; a read-only dialog focuses its surface, and the fallback close stays hidden until Tab reaches it; axe clean with the dialog open. Open BLOCK (AR4): when code opens the popover while focus is on the page, Escape returns focus to the body although the trigger is still mounted. AR4 says focus never returns to the body, and spec:AST-116 FR20 step 2 sends it to the trigger (WCAG 2.2 SC 2.4.3). The record's gap lines cover only a removed opener, so this case is not among them; the FR20 work in #11121 owns the repair. Open FIX (AR3): isModal={false} still holds Tab, and Escape closes a non-modal popover wherever focus is (the record's AR3 gap; spec:AST-116 FR12, FR15, FR16; #11156). A FIX, not a BLOCK: Escape and the fallback close still let focus leave, and the docs say isModal only sets aria-modal
§2 Theming 14 4.5 scored; the canonical popover target on the painted surface; token values only; light and dark checked. Open FIX (read from source): the surface paints its background but sets no text color, so inherited text takes the browser's color. The receipts record the surface's computed color, but the theme root reads the same value, so they cannot show the gap; spec:AST-038 FR3 keeps a color/background pair with one owner. #11451 owns the repair
§3 Public API 14 5 scored; the props in source match the docs in both languages; displayName; one canonical target
§4 Behavior 12 5 scored; below and above placement, start alignment in both directions, an explicit 280 px width, conditional scroll for tall content, outside press and Escape dismissal. The one-frame input-hold delay in the record's Current-state impact is a recorded tradeoff with FR9, not scored
§5a Design, objective 6 5 scored from source; surface paint, radius, shadow, and padding from tokens
§5b Design, rendered 4 5 scored from receipted frames in light, dark, both directions, 320 px, and forced colors
§6 Testing 8 5 scored; unit, presentation, motion, forced-colors, keyboard, focus-return, and second-document suites
§7 Code health 8 5 scored; observers and listeners exist only while open (PR1)
§8 Docs 8 5 scored; every prop, best practices, examples, and theming targets
§9 i18n and RTL 5 5 scored; the close label comes from the message catalog; the curated right-to-left check that the surface opens on the correct side, and the right-to-left frames, align the surface to the trigger's inline start
§10 Responsive and touch 5 5 scored; at 320 px the surface stays inside the viewport with no sideways scroll; tall content scrolls inside the surface

§11 is not run for an existing core component.

Why the score did not move: this pull request adds evidence only. Each open finding is fixed in an open pull request or needs an owner decision.

Needs Review

  1. Focus return after a code open (open BLOCK). Owned by the spec:AST-116 FR20 work (fix(core): one focus return for Popover and DropdownMenu (popover presentation) and Dialog that never strands focus (AST-116 FR17–FR21, AR1) #11121). The record's AR4 gap line names only a removed opener; this case, with the trigger still mounted, could be added to it in a later owner-approved record update. Each read-only receipt records the finding.
  2. Non-modal popovers (open FIX). Owned by feat(usePopover): tabBehavior lets Tab pass through a popover (spec:AST-116 FR12–FR15, AR4) #11156.
  3. Surface text color (open FIX). Owned by fix(Popover, HoverCard): surfaces paint the theme's text color, not the browser's CanvasText #11451.
  4. Fallback close placement (owner question, not scored). When Tab reveals the hidden close control, it renders centered below the painted surface, as its source intends. No current record covers where it appears.

Evidence

  • Audit spec: PopoverAudit.a11y.chromium.spec.ts drives existing Popover stories. Every frame has a receipt bound to the Storybook build and checkout: story id, theme, mode, direction, forced colors, viewport, DPR 2, settled fonts, and no page errors. Checks:
    • keyboard (Default; light and dark, both directions): closed state, open semantics, below placement, start alignment, 280 px width, inside the viewport, focus entry on the first switch with the ring, axe clean, five Tabs that stay inside, and Escape returning focus to the trigger;
    • pointer (Default; light and dark): focus entry with no ring, and an outside press that closes;
    • above (Above; light and dark): the surface above the trigger, inside the viewport, axe clean;
    • read-only (Read-only dialog focus; light and dark): the surface takes focus, the fallback close is hidden until Tab reaches it, Shift+Tab stays inside, and the receipt records where focus lands after Escape (the body) without failing on it;
    • narrow (Default at 320 px), tall content (Tall content overflow at 320 px), and forced colors (Default: a 1 px surface edge and the focus ring).
  • First run: Audits at head run 44549165492 at 51d4396eae1 failed on two measurement errors in the spec (it read aria-controls against the painted surface rather than the layer that holds it, and read the hidden close control's 1 px clipped box as visible) and on the focus return above. The spec now reads both as the runtime renders them and records the focus return.
  • Exact-head run: Audits at head run 44574231669 at this head: all 13 receipts pass, each bound to checkout and build 745f475bc16. Frames and receipts are in its contract evidence artifact.
  • Visual acceptance: N/A: no file a story renders changed.

Closed evidence inventory

Surface Source Tests Consumer docs Rendered evidence Authority Result
Trigger relationship usePopover.tsx unit suites — every open frame AR1 pass
Dialog semantics and label usePopover.tsx unit suites label, role, isModal every open frame AR2 pass
Focus entry, keyboard and pointer Popover.tsx unit and keyboard suites hasAutoFocus keyboard, pointer, read-only frames FR2 pass
Tab containment useFocusTrap unit and keyboard suites — keyboard, read-only frames AR3 pass
Escape and focus return Popover.tsx, layer runtime focus-return suite hasEscapeDismiss keyboard, read-only frames AR4, spec:AST-116 FR20 step 2 open BLOCK (code open; #11121)
Non-modal behavior usePopover.tsx — isModal — AR3, spec:AST-116 FR12–FR16 open FIX (#11156)
Placement and alignment layer runtime unit suites placement, alignment keyboard, above frames spec:AST-059 pass
Width and viewport fit Popover.tsx unit suites width keyboard, narrow frames ORD2 pass
Conditional scroll Popover.tsx unit suites — tall frame FR4 pass
Forced-colors edge usePopover.tsx forced-colors suite — forced-colors frame FR10 pass
Surface text color usePopover.tsx — — — (read from source) spec:AST-038 FR3 open FIX (#11451)
Fallback close usePopover.tsx unit suites hasCloseButton, closeButtonLabel read-only frames FR2, AR3 pass (placement: owner question)
FR10 eligibility report
{
  "schema": "astryx.audit-eligibility/v1",
  "component": "Popover",
  "package": "core",
  "mode": "night-watch",
  "rubricVersion": "1.16.6",
  "repository": {"base": "75649f57fd8", "head": "745f475bc16d16b1a58b2ef0052d6a80dfbb4cfb"},
  "contract": {"id": "component:Popover", "authority": "current", "changed": false},
  "inventory": {"closed": true, "rows": 12},
  "remediations": [],
  "unresolved": {
    "objective": ["AR4 focus return to the body after a code open with the trigger mounted (spec:AST-116 FR20 step 2; open pull request)", "AR3 non-modal popovers hold Tab (open pull request)", "surface sets no text color (spec:AST-038 FR3; open pull request)"],
    "manual": ["fallback close placement", "record AR4 gap line covers only a removed opener"]
  },
  "approvals": {"specOwner": "n/a (no record change)"},
  "verdict": {"autoMergeEligible": false, "reasons": ["AST-029 FR11 activation has not shipped", "open BLOCK AR4"]}
}

Overlap checked: #11121, #11156, #11122, #11132, #11451, and #12842 change Popover source or records; this pull request adds one test file.

@vercel

vercel Bot commented Nov 19, 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 19, 2026 5:19pm UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Nov 19, 2026, 5:29 PM UTC

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

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run concluded skipped. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

@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: three of the audit spec's sensors misreport, so the Popover audit receipts would not match what Popover does.

  • The fallback-close read (PopoverAudit.a11y.chromium.spec.ts:221) counts the hidden 1 × 1 px clipped wrapper as visible. Both read-only cases then fail on a correct Popover, and the post-Tab reveal check cannot fail; decide visibility from the wrapper's computed clip-path (inset(50%) hidden, none shown), or require more than 1 px.
  • The keyboard and forced-colors focus-ring checks (lines 248-249, 359-362 and 578-581) read the outline of the Switch's transparent input, which Chromium sets to auto 1px, not the track that paints the ring. So they pass with no visible ring; for a switch, read the outline from active.nextElementSibling.
  • The text-contrast check (lines 192 and 279) selects only .astryx-text, which the Default story's heading and switch labels do not carry, and it passes an empty set. So seven cases record minTextContrast: null as a pass; measure every visible text element in the surface, and fail when none is measured.

Also consider asserting the Tab order (lines 369-376) and emptying the evidence folder with resetAuditEvidence (line 588). The other checks match the Popover contract.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim, title: keyboard, pointer, placement and narrow-screen behavior is checked in a real browser. Verified as coverage: the spec has cases for each area (lines 313-585), though it has not run on this head yet.
  • Claim, description: this is a whole-component audit of Popover still in progress, with the scorecard, findings and evidence to follow. Accurate as stated: the pull request holds only the spec so far.
  • Claim, file header: CI runs the spec only for a Popover audit pull request. Verified: the @pr-a11y audit Popover line matches the documented audit route and this pull request's title.
  • Claim, file header: the spec covers modes, direction, forced colors and a narrow viewport. Verified (case list, lines 313-585).
  • Claim, file header: the sensor receipts are fail-closed. False for the focus-ring and text-contrast checks (findings 2 and 3).
  • File: packages/core/src/Popover/__tests__/PopoverAudit.a11y.chromium.spec.ts: the three findings above, plus two non-blocking suggestions.

Automated review (maintainer link)

`trigger aria-controls ${t?.controls}, surface id ${s?.id}`,
);
check(
(s?.minTextContrast ?? MIN_TEXT_CONTRAST) >= MIN_TEXT_CONTRAST,

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.

With no .astryx-text in the surface, minTextContrast is null and this passes. The Default story's Settings content is a Heading (astryx-heading) and Switch labels and descriptions from FieldLabel (astryx-field-label), so the seven Default-story cases never measure contrast. Measure every visible text-bearing element (for example, the parent of each non-empty text node in the surface), and fail when none is measured:

check(
  s?.minTextContrast != null && s.minTextContrast >= MIN_TEXT_CONTRAST,
  `surface text contrast ${s?.minTextContrast}`,
);

read.active?.inSurface === true,
`Tab ${i + 1} left the popover`,
);
order.push(read.active?.name?.trim());

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: order is recorded but never asserted, so a trap that swallowed Tab without moving focus would pass. The contract's Tab row requires moving to the next control and wrapping. Consider asserting ['Notifications', 'Dark mode', 'Sounds', 'Close popover', 'Notifications'].

@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: two of the audit spec's sensors still pass without measuring, so the Popover audit's keyboard-ring and text-contrast receipts are not evidence. The fallback-close read is fixed.

  • The keyboard and forced-colors focus-ring checks (lines 367-371 and 585-589) read the outline of the Switch's transparent input (lines 256-258), which Chromium sets to auto 1px, not the track that paints the ring; read it from active.nextElementSibling for a switch and fail on none.
  • The text-contrast check (line 287) passes when the .astryx-text selection (line 192) finds nothing, which happens in every Default-story case because its heading and switch labels do not carry that class; measure every visible text element in the surface and fail when none is measured.

Also consider asserting the Tab order (lines 376-385), emptying the evidence folder with resetAuditEvidence (line 595), and describing the code-open focus return as a gap the record does not list yet, since its FR20 gap line covers only a removed opener.

Claims and files checked

Review mode: incremental; reason: none

  • Claim: no behavior changes. Verified: the only changed file is a test spec.
  • Claim: every frame has a receipt bound to the Storybook build and checkout, with story, theme, mode, direction, forced colors, viewport, DPR 2, settled fonts and no page errors. Verified (lines 594-618 and 624-698).
  • Claim: keyboard entry draws the focus ring. Not established by the spec: its ring read measures the transparent input (first finding).
  • Claim: Tab cycles the switches and the fallback close and stays inside. Containment verified (lines 376-385); the order is recorded, and the first run's receipts show it wrapping.
  • Claim: a read-only dialog focuses its surface, and Tab reveals and reaches Close popover. Verified (lines 484-501), with the corrected visibility read (lines 221-224).
  • Claim: the trigger's popup relationship names the layer that holds the dialog. Verified against the runtime (lines 225-229).
  • Claim: the first run failed on two measurement errors and on the focus return. Verified from that run's log.
  • Claim: frames and receipts are in the exact-head run's evidence. Not yet checkable: that run was still in progress.
  • Claim: the code-open focus return is a gap the record lists. Imprecise: the record's gap line covers only a removed opener (non-blocking).
  • Claim: the scores and section ratings. Not checkable against the code; they are the audit's own scoring.
  • File: the Popover audit spec: the two findings above, plus three non-blocking notes.

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.

Changes requested: two of the audit spec's sensors still pass without measuring, and the description's exact-head evidence comes from the previous head.

  • The keyboard and forced-colors focus-ring checks (lines 373-377 and 598-602) read the outline of the Switch's transparent input (lines 262-264), which stays auto 1px with or without the visible track ring; read it from active.nextElementSibling for a switch and fail on none.
  • The text-contrast check (line 293) passes when the .astryx-text selection (line 192) finds nothing, which is every Default-story case because that content is a Heading and Switch labels; measure every visible text-bearing element in the surface and fail when none is measured.
  • The description's exact head, its exact-head run and its eligibility report all name the previous head, so none of the cited receipts comes from this spec; rerun the audit at this head and update them.

The new surface text-color fields read the same value for the surface and the theme in the neutral theme, so they cannot show the default-text-color finding yet; the inline notes give the details and a corrected Tab order to assert.

Claims and files checked

Review mode: incremental; reason: none

  • Claim: no source, story or doc file changes. Verified: the only changed file is the audit spec.
  • Claim: the receipts come from the exact head. False: the head, run and eligibility report name the previous head.
  • Claim: keyboard entry draws the focus ring. Not established: the read measures the switch's transparent input.
  • Claim: the receipts are fail-closed, text contrast included. False for the Default story: no text is measured and the check passes.
  • Claim: the fallback close and the popup relationship are read as the runtime renders them. Verified: lines 226-234 match the fallback wrapper's clip and the layer that aria-controls names.
  • Claim: the focus return after a code open is a gap the anchoring record already lists. False: that record lists only a removed opener, and the trigger stays mounted.
  • Claim: the surface renders the browser's default text color instead of the theme's. Not shown by the receipts: in the neutral theme both colors are the same.
  • File packages/core/src/Popover/__tests__/PopoverAudit.a11y.chromium.spec.ts: the three blocking findings above.

Automated review (maintainer link)

Comment on lines +262 to +264
outline: activeStyle
? `${activeStyle.outlineStyle} ${activeStyle.outlineWidth}`
: null,

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.

The focused element here is the Switch's input[role=switch], which has opacity: 0 (Switch.tsx:319-330). Its outline reads auto 1px whether or not the track ring (Switch.tsx:513-524) is drawn: on this head it stays auto 1px after the track ring is removed. So the keyboard checks (lines 373-377) and the forced-colors check (lines 598-602) pass with no visible ring. Read the ring from the element that paints it, for example active.nextElementSibling when role === 'switch', and fail on none.

border: `${style?.borderTopStyle} ${style?.borderTopWidth} ${style?.borderTopColor}`,
color: style?.color ?? null,
themeTextColor: (() => {
const root = document.querySelector('[data-astryx-theme]');

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 root Theme also sets data-astryx-theme on <html> (Theme.tsx:338-342), so this reads <html>'s color, not the story's Theme wrapper that line 74 reads. In the neutral theme --color-text-primary is light-dark(#000000, #ffffff), the same as CanvasText, so color and themeTextColor both read rgb(0, 0, 0) in light and rgb(255, 255, 255) in dark and cannot show the default-text-color finding. Scope the selector as line 74 does ('#storybook-root [data-astryx-theme]'), and record the finding where the two values can differ.

read.active?.inSurface === true,
`Tab ${i + 1} left the popover`,
);
order.push(read.active?.name?.trim());

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, correcting the earlier suggestion on this line: focus enters on Notifications, and the first run recorded Dark mode, Sounds, Close popover, Notifications, Dark mode. The order to assert is ['Dark mode', 'Sounds', 'Close popover', 'Notifications', 'Dark mode'].

This branch was successfully deployed

1 active deployment
Preview — 745f475b Deployed Nov 19, 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