Skip to content

fix(core): preserve keyboard focus at navigation boundaries - #6304

Closed
jiunshinn wants to merge 2 commits into
meta:mainfrom
jiunshinn:codex/issue-5602-edge-nav-focus
Closed

jiunshinn wants to merge 2 commits into
meta:mainfrom
jiunshinn:codex/issue-5602-edge-nav-focus

Conversation

@jiunshinn

Copy link
Copy Markdown
Contributor

User impact

Keyboard users navigating to the first or last page, month, or gallery item lose their place when the focused navigation button becomes disabled. Pagination, Calendar, Lightbox and DateInput's custom touch picker now keep keyboard focus on an available control in the same component.

Closes #5602.

Problem and solution fit

Native disablement removes focus from the active button. The user loses their position in the page and must find the component again before continuing. A private helper synchronizes browser focus with the committed availability transition, then moves focus once with preventScroll: true.

The committed transition matters for controlled owners that ignore or defer requests, cursor results that change hasMore, and updated bounds. An enabled blur or a newer active target releases ownership. Pointer navigation retains native focus behavior, including browsers that do not focus clicked buttons.

Expected behavior and authority

Interaction modality INV1, INV5, INV7 and INV8 require consistent modality, disabled semantics, reachable actions and newer-intent precedence. React component runtime INV2–INV3 distinguish requested actions from committed external-system synchronization. WCAG 2.2 SC 2.4.3 supplies the focus-order outcome.

This claim concerns browser focus, keyboard operation and focus-ring visibility. It makes no spoken-output or assistive-technology mode claim; AST-009 FR2/FR7 therefore use browser and DOM evidence here.

Smallest restoration

  • Pagination and Calendar use the available opposite arrow. Pagination falls back to its labelled landmark, made programmatically focusable with the existing shared outline. Calendar falls back to its existing day-grid tab stop when both arrows become unavailable.
  • Lightbox uses the opposite gallery control, or Close if the gallery becomes a single item. Its already-fixed intermediate navigation remains unchanged.
  • The touch DateInput picker uses its existing month/year title control.
  • The shared helper remains private; native disabled semantics, controlled/optimistic state, callbacks, public refs, theme targets, layouts and grid/dot keyboard navigation retain their owners.

Evidence

  • Reproduction before the change: Chromium keyboard activation reached <body> after 9 Pagination Next presses, 2 Calendar Next presses, 3 Lightbox Next presses, and 1 Previous-month press in the custom touch DateInput picker with a two-month bound. Lightbox's intermediate item already retained focus on current main.
  • Result after the change: Chromium and WebKit pass 40 combinations covering both boundaries, light/dark, LTR/RTL, keyboard use with coarse-pointer emulation, pointer input after keyboard input, and subsequent native Tab navigation. Keyboard focus lands on the named receiver with the existing outline; pointer navigation introduces no outline.
  • Representative unchanged path: intermediate navigation retains its button, native dialog/browser-chrome Tab handling is preserved, dot arrow-key selection remains operable, and pointers keep their native focus behavior.
  • Regression test or other mutation-sensitive proof: focused tests cover two-item ranges, all four Pagination arrows, delayed cursor/controlled updates, pending Action settlement, ignored requests, newer focus, native disablement blur, node replacement, initial disablement, StrictMode replay, gallery shrinkage, two-month Calendars, and keyboard → pointer → keyboard transitions.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • 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 lint:strict — passes; 84 existing warnings, no errors.
  • pnpm build — passes after the final runtime change.
  • Focused Vitest component/helper suites — 627 tests pass.
  • pnpm test --maxWorkers=4 — 16,999 passed, 50 skipped; the two failing GNU cp --reflink=auto cases in internal/vibe-tests/setup-test/setup-workspace.test.mjs also fail on clean main on macOS. All changed component/helper tests pass.
  • Real Chromium and WebKit runtime: 56 passing cases — the 40-case matrix above, plus 16 Pagination count/compact/none/dots/input/stride cases and return from pointer input to keyboard input. WebKit uses its Option-Tab path for all-control keyboard navigation; a native browser-chrome stop is distinguished from document focus.

@vercel

vercel Bot commented Sep 13, 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 Oct 3, 2026 11:33pm UTC

Request Review

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

astracat-bot Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Oct 20, 2026, 12:01 AM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Sep 13, 2026
@jiunshinn
jiunshinn marked this pull request as ready for review September 13, 2026 02:35
github-actions Bot added a commit that referenced this pull request Sep 13, 2026
@github-actions

github-actions Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Calendar (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1502 -
Complexity N/A Very High (144) -
DateInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 3364 -
Complexity N/A Very High (360) -
Lightbox (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 705 -
Complexity N/A Very High (90) -
Pagination (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 679 -
Complexity N/A Very High (100) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

14 of 420 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Chat Full AI Chat probe light 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,229
Chat With Attachments probe dark 11,065
Markdown Default probe dark 897
Markdown Default probe light 897
Markdown Default neutral dark 882
Markdown Default neutral light 858

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

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

The focus-recovery behavior is covered by the focused suites, but the new helper regression test does not type-check, so the PR’s required build and dependent CI lanes cannot complete. Please type the queried Next element as an HTMLButtonElement before assigning .disabled and rerun the Core typecheck.

@jiunshinn
jiunshinn force-pushed the codex/issue-5602-edge-nav-focus branch from 88ec968 to 00fefb2 Compare October 3, 2026 23:27
@jiunshinn

Copy link
Copy Markdown
Contributor Author

Rebased onto main (73a6506d60) and fixed the requested HTMLButtonElement query before assigning .disabled. The Lightbox conflict retains current LayerContentBoundary/text-reset behavior and adds the navigation refs/focus recovery to the current controls.

Validation: all 384 focused navigation tests, Core typecheck, strict lint/repository checks, and the full package build pass. The full repository run passed 20,226 tests with 9 failures; all 149 tests in the three failing UI files pass on an isolated rerun. The remaining failures are in unchanged tooling that requires GNU cp --reflink=auto or newer Bash array behavior than macOS's Bash 3.2. The full suite is therefore not reported as green on this machine.

@cixzhang @astracat-bot Please re-review the updated head. The reported TS2339 blocker is fixed.

The formal review-request API rejects my account's permissions in this repository, so this comment is the re-review request; existing reviewer assignments are retained.

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

The fix works: in Chromium, keyboard focus that used to fall to the page body at the last page, month or gallery item now stays on a control inside Pagination, Calendar, Lightbox and the touch DateInput picker, and the new boundary tests fail without the change and pass with it. Approval waits on a maintainer to provide or identify the governing spec for where focus lands in each component: the shared interaction guidance leaves focus destinations to component records, and those records are still drafts. What must be settled is whether these receivers become the components' behavior: the opposite control in Pagination, Calendar and Lightbox, with Pagination's labelled landmark (now always tabindex="-1"), Calendar's day grid and Lightbox's Close as fallbacks, and the month/year title rather than the adjacent opposite arrow in the touch picker. No code change is requested before that decision; afterwards, please rebase onto main, which now conflicts in four files.

[Automated review]

cixzhang added a commit that referenced this pull request Oct 14, 2026
…docs (#7372)

## User impact

Builders reading DateInput's API reference could not find `containerClassName`, `containerStyle`, `controlClassName`, or `controlStyle`, even though DateInput accepts them and they are the only class-name and inline-style hooks it has after root styling was removed. The English, Chinese, and dense references now list all six part-styling props, like the other field components. The draft contract now matches DateInput's current behavior. Runtime behavior does not change.

## Audit scope

- Package/component: `core/DateInput`
- Base: `1e883f86e7aa5c2be376671f746d79e5cfae769b`
- Frozen head: `4faee79d299c5f4661bfecbb01a7aade966440ee`
- Mode: Night Watch whole-component audit · Rubric: **1.16.6**
- Runtime/API changes: none (API reference, draft contract, and a `[docs]` Changeset)
- Landing: held until the 0.7.0 release is tagged.

## Score

- Before: **85.6 / C** — 2 open BLOCKs; §5b not measured.
- After: **87.3 / C**, confirmed by the exact-head checks — the same 2 BLOCKs, both owned by open contributor pull requests (see Needs Review).
- Sensitivity: resolve the 2 open BLOCKs and change nothing else → **99.0 / A**.
- Sections §1, §2, §3, §4, §5a, §5b, §6, §7, §8, §9, §10 — before `3, 5, 5, 3, 5, nm, 5, 5, 4, 5, 4`; after `3, 5, 5, 3, 5, nm, 5, 5, 5, 5, 4`.

## Findings

| ID | Section | Finding | Authority | Result |
|---|---|---|---|---|
| D1 | §1 A5 — BLOCK | In the bottom-sheet calendar, the month arrows become natively disabled at the first or last reachable month, so a keyboard user who steps onto that month loses focus to the document. | `architecture:interaction-modality`; WCAG 2.2 SC 2.4.3 | **Open.** #6304 already fixes it; not duplicated here. |
| D2 | §4 B15 — BLOCK | After a clear, the pointer surface passes `undefined` to Calendar, which treats it as uncontrolled, so reopening the calendar shows the cleared date as selected. A focused test at the exact head reproduces it: one day stays selected after clear and reopen. | DateInput clear contract (FR1, FR11); Calendar's documented controlled-empty `null`; WCAG 2.2 SC 4.1.2 | **Open.** #6935 already fixes it; not duplicated here. |
| D3 | §8 X5b — FIX | The API reference omitted `containerClassName`, `containerStyle`, `controlClassName`, and `controlStyle`, which DateInput accepts under `family:input-fields/FR10`; the other field members list them. | `family:input-fields/FR10`; rubric X5b | **Fixed** in the English, Chinese, and dense references. |
| D4 | §8 — FIX | The draft contract described the removed `date-input-clear-icon` alias and did not cite the FR10 base-prop and part-styling rule DateInput now follows. | Current source; `family:input-fields/FR10` | **Fixed.** The contract cites FR10 and the current clear-glyph target; the FR10 suite joins `verified_by`. No new component requirement is added. |

Not scored: the bottom-sheet surface inherits BottomSheet's recorded shared-dismissal adoption gap (owned by BottomSheet under `family:overlay-dismissal`). The bottom-sheet calendar's day cells fade their colors without a reduced-motion collapse, but the motion record is still a draft, so no current authority applies.

## What changed

- `DateInput.doc.mjs` — four props entries in `docs` and `docsZh`, four `docsDense` descriptions, matching the sibling field components.
- `DateInput.spec.md` (draft) — cites `family:input-fields/FR10` in the governing rules and the family relationship, adds `DateInput.fr10.test.tsx` to `verified_by`, and names the current clear-glyph target.
- `.changeset/date-input-part-style-props-docs.md` — `[docs]` patch, because the API reference ships in the package.

## Evidence

- This PR changes no behavior, so no new functional test was added; typed docs validation and the doc-prop suites cover the docs change.
- Exact-head checks on `4faee79`: CI run 38256902974 succeeded, including build, lint, unit tests, docsite tests, and the Storybook build.
- `pr-a11y` audited all 26 DateInput stories: 0 violations and no new baseline entries.
- `pr-rtl` (core): `core/DateInput` passes the automatic check and its curated calendar/clear control-order check.
- Stable visual regression: see Visual acceptance.
- Owner-exempt `review-required` is success on `4faee79`, set by GitHub Actions through the repository's Review signal workflow. `spec-owner-approval` is success (draft record only), and the CLA check passes.
- A private review of the exact head, title, and description is clean.
- Local runs on the first head: DateInput, doc-prop, and theming suites — 757/757; `typecheck:docs`; `pnpm build`; docsite generate and tests — 620 passed, 6 skipped; `check:knowledge`; `check:changesets`. Later commits changed only draft-contract text, with `check:knowledge` re-run after each, plus one empty commit that retriggered a failed preview deployment.
- No local browser result is credited; browser evidence comes from the exact-head checks above.

## Closed evidence inventory

| Surface | Evidence | Result |
|---|---|---|
| Controlled ISO value, typing, constraints, formats | source; focused suites | pass |
| Five presentation values and deprecated mapping | `Presentation.test.tsx`; native and touch suites | pass |
| Pointer calendar open, select, close | source; tests; `OpenCalendarAudit` story | pass |
| Clear and calendar selection | source; focused test at the exact head | open — D2 |
| Bottom-sheet calendar, wheels, save | `DateInputTouch.test.tsx` | pass |
| Bottom-sheet month arrows at a bound | source | open — D1 |
| Native picker, Action, clear, focus continuity | `NativeDateField.test.tsx` | pass |
| Field states, status, disabled reason, InputGroup | focused suites; `AllVariations` | pass |
| FR10 base props and part styling | `DateInput.fr10.test.tsx`; `StylingParts` story | pass |
| API reference completeness | `DateInput.doc.mjs` | fixed — D3 |
| Theming targets | `themingTargets.test.ts`; themed stories | pass |
| Accessibility and RTL | exact-head `pr-a11y` (26 stories) and `pr-rtl` (core) | pass |
| Narrow viewport and coarse pointer pixels | none | not measured |

## Visual acceptance

Product visual delta: **N/A**. The change is limited to the API reference, the draft contract, and a Changeset; no component source, style, story, or rendered output changes.

The exact-head stable visual gate passed with verdict `changed`: 448 shots, 356 unchanged, 42 changed, 50 added, 22 removed, 0 failed, against a baseline captured on 2026-09-26. #7370's exact-head report, from a PR that changed no DateInput file, lists the same 42 changed, 50 added, and 22 removed shots. 41 changed shots match it pixel for pixel; the 42nd, a SideNav resize shot, also varies between runs of this PR. No DateInput shot changed: its 8 added and 2 removed shots appear identically in #7370's report. The verdict reflects baseline drift, not this PR.

## Knowledge overlap search

- Terms: `component:DateInput`, `DateInput.spec.md`, `containerClassName`, `controlClassName`, `FR10`, `date-input-clear-icon`, plus the path `packages/core/src/DateInput/`.
- Canonical owner: the existing draft `component:DateInput` at `packages/core/src/DateInput/DateInput.spec.md`; the FR10 rule stays with `family:input-fields` and is linked, not copied.
- Overlapping open work inspected: #6935 and #6304 own D2 and D1; #7358 changes translator imports; #6884, merged after this audit's base, changes only the bottom-sheet padding in `TouchDateField.tsx`; #6133 and #5939 are drafts. None edits `DateInput.spec.md`. DateRangeInput, DateTimeInput, and TimeInput carry the same API-reference gap; that is outside this audit.

## Review feedback

- Automated review asked that the contract not restate part of `family:input-fields/FR10` and then that it not add a draft requirement that no current spec states. The contract now only cites FR10; the earlier FR13 row and its verification row are removed. The automated review approved the final head.

## Needs Review

- **D1** — focus at the bottom-sheet month bounds: owned by #6304.
- **D2** — stale calendar selection after clear: owned by #6935.
- **Merge timing** — held until the 0.7.0 release is tagged.

## Writing rubric results

- R1 narration: none; the contract states current behavior.
- R2 research: none.
- R3 evidence: facts and standards, not changes.
- R4 rejected alternatives: none.
- R5 change references: none.
- R6 open questions: none.

## FR10 exact-head report

```json
{
  "schemaVersion": 1,
  "component": "DateInput",
  "package": "core",
  "mode": "night-watch",
  "rubricVersion": "1.16.6",
  "repositoryBase": "1e883f86e7aa5c2be376671f746d79e5cfae769b",
  "repositoryHead": "4faee79d299c5f4661bfecbb01a7aade966440ee",
  "componentContractHead": "4faee79d299c5f4661bfecbb01a7aade966440ee",
  "inventory": {"closed": true, "rows": 13},
  "score": {"before": 85.6, "after": 87.3, "beforeBlocks": 2, "afterBlocks": 2},
  "unresolvedObjectiveGaps": [{"id": "D1", "rule": "A5", "owner": "#6304"}, {"id": "D2", "rule": "B15", "owner": "#6935"}],
  "unresolvedManualGaps": [],
  "remediations": [
    {"id": "D3", "state": "verified-source", "evidence": "six part-styling props listed in all three references"},
    {"id": "D4", "state": "verified-source", "evidence": "draft contract cites FR10 and names the shared clear glyph target"}
  ],
  "approvals": {"privateExactHeadSelfReview": "clean", "reviewSignal": "success (GitHub Actions)", "specOwner": "draft record only"},
  "checks": {"local": "green; no local browser", "exactHeadCI": "success (run 38256902974)", "a11y": "0 violations across 26 owned stories", "rtl": "automatic and curated checks pass", "visual": "N/A product delta; gate drift matches an unrelated PR"},
  "eligibility": {"eligible": false, "reasons": ["FR11 auto-merge inactive", "two open BLOCKs owned by contributor pull requests", "held until the 0.7.0 release is tagged"]}
}
```
cixzhang added a commit that referenced this pull request Oct 21, 2026
## Exact decision needed

Whether Astryx disabled controls may leave keyboard focus, and what happens when the control a user is on becomes disabled.

## Existing authority searched

- `family:buttons` FR3 (current): disabled blocks activation and MAY use focusable `aria-disabled` when a reason needs focus.
- `family:input-fields` FR4 (current): a field with `disabledMessage` stays "focusable enough" to expose the reason.
- `spec:AST-011` FR5 (current): disabled focus, paint, and submission win over read-only. Unchanged.
- `component:DateRangeInput` AR3 and `component:Tokenizer` (current) named native `disabled`; amended here. Draft records for ClickableCard, BaseTypeahead, CheckboxInput, ChatComposer, and CommentPin describe it as observed behavior and do not govern.
- `architecture:interaction-modality` INV1/INV5 (current): keyboard focus visibility and disabled non-interactivity.
- `spec:AST-009` FR2: focus destination needs browser evidence, not real-AT evidence.
- Shipped code: Button already keeps focus via `aria-disabled` for busy and tooltip cases; TextInput and CheckboxInput do so with a disabled reason. Pagination, Calendar, Lightbox, and the touch date pickers render native `disabled` on boundary arrows, so keyboard focus falls to the document body at the first or last page, month, or item.
- No current claim requires native `disabled`, and none decides what happens to focus when a focused control becomes disabled.

## Decision

- Components never render the native `disabled` attribute. Disabled controls expose `aria-disabled="true"` and keep their enabled focus order.
- Disabled blocks every value change, activation, navigation, surface opening, and callback.
- Disabled values are not submitted and do not block constraint validation, matching native form behavior.
- A control that becomes disabled while focused keeps focus unless the component's own record names a destination inside the component.
- Disabled state, name, and reason are exposed on the focusable element; disabled paint stays, hover and pressed affordances do not, and the keyboard focus indicator still shows.
- Group and form-level disablement follow the same rule.
- `family:buttons` FR3 and `family:input-fields` FR4 link to this record instead of carrying a weaker local rule.
- `component:DateRangeInput` (disabled presets, AR3) and `component:Tokenizer` (disabled state and its verification) no longer name native `disabled`; they follow this record.
- Disabled paint keys on the disabled state, so a busy Button keeps its pending treatment (`family:buttons` FR4).

## Rejected alternatives

- Moving focus to a component-chosen fallback whenever a control becomes disabled: every component needs its own destination and timing, and focus still jumps.

## Claim scope and non-goals

Which items arrow keys visit inside a composite widget, read-only behavior, disabled paint and theme states, and elements a caller renders inside a slot stay with their existing owners.

## Overlapping open work

- #6304 restores focus at navigation boundaries by moving it to a component-chosen fallback. DEC-1 rejects that approach; under this record the boundary control keeps focus instead.

## Evidence and implementation relationship

Keyboard reproduction in Chromium: focus reaches the document body after the boundary press in Pagination, Calendar, Lightbox, and the touch DateInput picker. No implementation is included. Conformance work follows separately; consumers who select disabled controls with `:disabled`, query them with `toBeDisabled()`, or rely on Tab skipping them see a change, which release notes will name. Affected consumer docs (Button, ClickableCard, Collapsible, TextInput, TextArea, NumberInput, `useInteractiveRole`) and native-disabled test cases in DateRangeInput and Slider are named in the record and change with conformance work.

## Writing rubric results

- R1 narration: none; the record states present-tense behavior. The family and component edits are present-tense cross-references.
- R2 research in the record: none.
- R3 evidence naming a change: none; verification cites test and browser layers.
- R4 rejected alternatives over one line or outside a decision: one, one line, inside DEC-1.
- R5 pull request or issue references remaining: none in the new record or the edited family lines.
- R6 ruled open questions still listing options: none; open questions section reads "None".

## Scope

- [x] This PR contains specification records only.
- [x] It records observable behavior and preserves equivalent internal implementations.
- [x] Any named internal mechanism is intentionally public, names its dependent caller/system, and explains why an equivalent implementation would not satisfy the contract.
- [x] Verification states the evidence layer and failure signal without prescribing CI job/workflow topology.
- [x] It records one intentional durable decision, not a rescue for a separable tagalong.
- [x] The canonical knowledge owner, affected current claims, and overlapping open work are named; any ownership collision is resolved or called out for human decision.
- [x] Adjacent API, visual, accessibility, composition, and implementation facts remain outside scope unless this exact decision depends on them.
- [x] Public text and artifacts contain no internal Meta context.

## Validation

- `pnpm check:knowledge`
- Prettier
- `git diff --check`
@jiunshinn jiunshinn closed this Oct 27, 2026
@github-actions
github-actions Bot deleted the codex/issue-5602-edge-nav-focus branch October 28, 2026 12:15

This branch was successfully deployed

1 active deployment
Preview — 00fefb27 Deployed Oct 3, 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. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edge nav controls drop keyboard focus to the document body when a press disables them

1 participant