Skip to content

[Component Audit] DateRangeInput: keep range state truthful - #7297

Merged
cixzhang merged 1 commit into
mainfrom
night-watch-component-audit/DateRangeInput/2026-10-10
Oct 10, 2026
Merged

cixzhang merged 1 commit into
mainfrom
night-watch-component-audit/DateRangeInput/2026-10-10

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

User impact

People using DateRangeInput with assistive technology can now hear required state without invalid ARIA, hear the same pending range that is visible while a change saves, and reopen a cleared calendar without the previous range appearing selected.

Problem and solution fit

Three state seams drifted apart:

  • the range trigger is a button, but it carried aria-required, which is not valid on that role;
  • its accessible name read the accepted value while the visible trigger read the optimistic value;
  • clearing passed undefined to Calendar, allowing Calendar to fall back to its old internal range.

The fix keeps the existing button contract. Required state uses the established localized hidden-description pattern, the trigger name and Calendar both consume the optimistic controlled value, and Calendar documents null as its explicit controlled-empty value.

Expected behavior and authority

  • DateRangeInput FR1 requires one controlled range without a competing selected range.
  • family:input-fields FR6 requires optimistic value feedback during changeAction.
  • The existing FileInput button-trigger pattern supplies required state through a localized aria-describedby target rather than unsupported aria-required.

Smallest restoration

  • Preserve the released button role, Enter/Space behavior, props, defaults, visuals, and theme targets.
  • Add no new caller decision. Calendar.value only widens its type to admit the null controlled-empty state already handled at runtime.
  • Remove the now-obsolete critical axe baseline entry.

Credit: this repair incorporates the problem reports and implementation evidence from #4689 and #6935.

Audit score

Rubric 1.16.6:

  • Before: 80.3 / C — 3 BLOCKs: invalid required-state ARIA, stale pending accessible name, and stale selected days after clear.
  • After: 93.1 / A — 0 open BLOCKs. Exact-head Actions will confirm the rendered/a11y/RTL sections before merge.

Changed sections: accessibility 2.5→4.5, behavior 3→5, testing 4→5. Other section scores are unchanged.

Evidence

  • Reproduction before the change: all three new DateRangeInput regressions fail against the base behavior; the required story also has the existing aria-allowed-attr baseline row.
  • Result after the change: 170/170 focused Calendar, DateRangeInput, and PowerSearch tests pass.
  • Representative unchanged path: ordinary range selection, preset selection, disabled reasons, and PowerSearch range rendering remain covered.
  • Independent exact-head private review: CLEAN at 94f81034f22306ca4329c111c6c2df0224ef1cfe.

Scope

  • One restoration: keep the field's required, pending, and selected range state truthful.
  • Separable role/keyboard and audit-fixture changes were removed.
  • No incompatible 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
  • pnpm build
  • Core and Storybook typechecks
  • Storybook production build
  • 170 focused assertions
  • Full Vitest suite with bounded workers: changed paths pass; transient CLI timeouts pass when rerun serially. Five unrelated current-main/environment failures remain in untouched Storybook taxonomy tests and GNU-specific setup-workspace tests. Exact-head Linux CI is the merge gate.

@vercel

vercel Bot commented Oct 10, 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 10, 2026 11:50am UTC

Request Review

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

astracat-bot Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 10, 2026, 12:01 PM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Previews ready: Storybook and Sandbox were built with this PR's docsite. CI evidence will be added when available.

View Storybook for this PR · View Sandbox for this PR

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

Thanks — this keeps DateRangeInput's range state truthful in three places that had drifted apart. Required state is now announced through a valid description on the button trigger (with the obsolete axe baseline exemption removed), the trigger's accessible name and the calendar follow the optimistic value while a save is pending, and clearing the field no longer brings the old selection back when the calendar reopens.

Calendar's newly documented value={null} controlled-empty state is additive and matches what the runtime already did, so existing calls are unaffected. I verified the focused Calendar/DateRangeInput and PowerSearch tests, the core typecheck, and before/after rendered axe results on the Required story; no blocking findings from me.

[Automated review]

@cixzhang
cixzhang merged commit 0d8dadb into main Oct 10, 2026
44 checks passed
@cixzhang
cixzhang deleted the night-watch-component-audit/DateRangeInput/2026-10-10 branch October 10, 2026 12:17
cixzhang pushed a commit that referenced this pull request Oct 14, 2026
## User impact

After selecting a date through DateInput's calendar, clearing the field and reopening the calendar still shows the previous date as selected. This fix keeps the empty field and Calendar selection consistent.

Fixes #6934

## Scope after rebase

Rebased onto `main` at `2514d86d02ffa32b1c17b32523e1149eb86334fe` and removed the portions already covered by:

- #7297: Calendar's controlled-empty support and DateRangeInput's clear behavior.
- #7298: DateTimeInput's clear behavior.

The remaining change is the DateInput composition and the original locale-consistency example, with regression evidence and a scoped patch changeset. Calendar, DateRangeInput, and DateTimeInput have no diff against the rebase target.

## Problem and solution fit

Calendar treats `undefined` as uncontrolled. Selecting a date updates its internal selection; passing `undefined` after DateInput clears lets that old selection become visible again.

DateInput now passes `optimisticValue ?? null` to Calendar, following the same controlled-empty boundary used by DateTimeInput in #7298. DateInput's public value type, `onChange(undefined)` clear callback, optimistic change pipeline, and picker presentation stay unchanged.

## Expected behavior and authority

- [DateInput's consumer documentation](https://github.com/facebook/astryx/blob/2514d86d02ffa32b1c17b32523e1149eb86334fe/packages/core/src/DateInput/DateInput.doc.mjs) describes clear as resetting the selected value.
- [Calendar's existing consumer documentation](https://github.com/facebook/astryx/blob/2514d86d02ffa32b1c17b32523e1149eb86334fe/packages/core/src/Calendar/Calendar.doc.mjs) defines `null` as controlled-empty and omitted/`undefined` values as uncontrolled.
- Once the parent accepts clear, the reopened calendar should have no selected gridcells. Visible month, today's marker, and keyboard focus remain separate from selection.
- No public API or type widening remains in this PR.

## Smallest restoration

- Normalize DateInput's empty value to `null` only at its Calendar boundary.
- Keep the locale-consistency example's Calendar controlled when its shared date is empty.
- Add a select → clear → reopen unit regression and a `ClearedCalendarSelection` Storybook play function, following #7298's evidence pattern.
- Narrow the changeset to DateInput; retain contributor attribution.

## Evidence

- **Before:** without the DateInput boundary normalization, the new regression fails with one selected gridcell instead of zero.
- **After:** the test verifies that a calendar selection exists before clear, that clear empties the input, and that reopening leaves zero selected gridcells.
- **Browser endpoint:** `Core/DateInput/ClearedCalendarSelection` selects April 15, clears, reopens, and asserts an empty field with no selected day. Its final open-calendar frame is tagged `visual-baseline`.
- **Representative unchanged paths:** related suites cover ordinary selection, constraints, callbacks, native and touch presentations, and the already-merged Calendar/DateRangeInput/DateTimeInput clear behavior.
- No CSS, geometry, token, role, or DOM-anatomy change. Only the stale selected-day state is removed. This is not a new cross-browser or assistive-technology audit.

## Scope

- [x] One remaining stale-selection defect is restored.
- [x] Already-merged sibling and Calendar changes are removed.
- [x] No new public API, visual representation, default, or interaction model is introduced.
- [x] Public text and artifacts contain no internal operational context.

## Testing

- `pnpm build` — passed.
- `pnpm -F @astryxdesign/core typecheck` and `pnpm -F @astryxdesign/storybook typecheck` — passed.
- Commit hooks (staged-file ESLint/Prettier and `pnpm check:repo`) — passed; the user-reviewed patch is unchanged by the hooks.
- `pnpm lint:strict --ignore-pattern 'assets/**'` — passed. The plain command picked up a local, ignored generated bundle under `assets/`; that directory contains no tracked files. No repository lint rules or configuration were changed.
- `pnpm test --maxWorkers=4` — **22,668 passed, 2 failed, 2 expected failures, 40 skipped**. All DateInput and related date-component suites pass. The only failures are the two taxonomy assertions in `apps/storybook/.storybook/story-tree.test.ts`, which read a pre-existing local Storybook index. Both failures were independently reproduced with the exact `main` version of that test and the same index; the test itself is unchanged. They are not reported as passing and are outside this fix.
- Headless Chromium, `Core/DateInput/ClearedCalendarSelection` — passed: empty field, reopened calendar, zero selected gridcells, no page errors.
- `git diff --check` — passed.

This branch was successfully deployed

1 active deployment
Preview — 94f81034 Deployed Oct 10, 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