Skip to content

fix(DateRangeInput): expose trigger as combobox - #4689

Closed
AKnassa wants to merge 4 commits into
meta:mainfrom
AKnassa:rocky/issue-4681-aria-allowed-attr
Closed

AKnassa wants to merge 4 commits into
meta:mainfrom
AKnassa:rocky/issue-4681-aria-allowed-attr

Conversation

@AKnassa

@AKnassa AKnassa commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Part of #4681 (weekly a11y scan). Clears the critical DateRangeInput::Required::aria-allowed-attr baseline entry.

What this does

The date range picker's trigger button carried aria-required, which ARIA does not allow on role=button, so axe flagged it as critical. The trigger is now exposed as role="combobox", the same decision DateInput and DateTimeInput already made for their triggers, which makes aria-required and aria-invalid legal and announces the control as what it behaves like: a collapsed picker that opens a dialog.

What changed

  • role="combobox" on the trigger button in DateRangeInput.tsx. The existing aria-expanded, aria-haspopup="dialog" and aria-controls wiring already matches the pattern.
  • Trigger test queries move from button-role to combobox-role. The accessible name (label plus value or placeholder) is pinned by name-matched assertions and is mutation-proven: removing the trigger's aria-label fails 2 tests.
  • Baseline: 1 entry removed, deletions only.
  • Changeset (patch): consumers who query the trigger with getByRole('button', {name}) need to target combobox instead; screen readers now announce "combobox, collapsed" rather than "button".

Considered and rejected

Dropping aria-required from the button was the smaller diff, but it silently removes the required announcement and diverges from both sibling date inputs.

Not in this PR

The 10 remaining aria-allowed-attr entries (ChatComposerInput x8, ChatLayout x2) all trace to one node: the composer's editable div flips to role=combobox when triggers are configured while keeping a hardcoded aria-multiline. That file is owned by open PR #4074; the fix belongs there and the entries stay baselined until it lands.

Verification

41/41 DateRangeInput tests (plus width-contract and status-icon suites, 85/85), eslint clean, and the repo's axe audit with --fail-on-new: 0 issues across all 17 DateRangeInput stories.

axe flagged aria-required on the trigger (critical aria-allowed-attr):
the attribute is not allowed on role=button. DateInput and DateTimeInput
already expose their triggers as role=combobox with aria-haspopup=dialog,
so this aligns DateRangeInput with the sibling decision instead of
silently dropping the required announcement.

Trigger tests move to combobox-role queries; the accessible name
(label + value/placeholder) is pinned by name-matched assertions,
mutation-proven against aria-label removal. Baseline: -1 entry.

Verified: 41/41 tests, eslint clean, axe audit 0 issues across all
17 DateRangeInput stories with --fail-on-new.

Part of meta#4681.
@vercel

vercel Bot commented Aug 3, 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 Sep 26, 2026 7:17pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 3, 2026
@AKnassa
AKnassa marked this pull request as ready for review August 4, 2026 01:48
@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 Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 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

DateRangeInput (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 559 -
Complexity N/A Very High (72) -
PowerSearch (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 3852 -
Complexity N/A Very High (335) -

Bundle Size Summary

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

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

PowerSearch - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/26 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Visual Regression

1 of 420 shot(s) changed. View the report

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
SideNav Resizable in AppShell probe dark 3,208
SideNav — Resizable in AppShell — probe dark
BeforeAfterDiff
Before visual regression frame After visual regression frame Pixel difference frame

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

@cixzhang cixzhang 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 — routing through combobox rather than dropping aria-required is the right call.

One gap before it lands. DateInput implements the keyboard half of that pattern (DateInput.tsx:663 — ArrowDown and Alt+ArrowDown open the calendar); this trigger has no onKeyDown at all. So a screen-reader user hears "combobox, collapsed", presses Down Arrow because that is what the role promises, and nothing happens — where the same press on DateInput opens the picker. Enter and Space still work, so it is incompleteness rather than a break.

if (!popover.isOpen && e.key === 'ArrowDown') { e.preventDefault(); handleToggle(); }

The popup here is a dialog rather than a listbox — should ArrowDown move focus into the calendar, which handleToggle already does, or keep it on the trigger the way DateInput does with skipAutoFocus?

If you would rather talk it through with a person, we are in Discord.

[Reviewed by Robohands]

type="button"
// Select-only combobox, matching DateInput/DateTimeInput: makes
// aria-required/aria-invalid valid here (not allowed on role=button).
role="combobox"

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 role now promises ArrowDown opens the popup; this button has no key handler.

@cixzhang

Copy link
Copy Markdown
Contributor

Checking in on the combobox keyboard gap: Down Arrow still needs a defined open-and-focus behavior matching the announced role. Would you like to continue, have us carry it, or close this for now?

@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 — exposing the trigger as a combobox (matching DateInput/DateTimeInput) is the right fix for the critical aria-required axe violation, and the baseline removal, name-pinned tests, and changeset note are clear.

One change is needed before approval: the trigger now announces "combobox, collapsed" but has no keyboard opening path. DateInput opens on ArrowDown (and Alt+ArrowDown) when closed, disabled-guarded — this trigger only handles click, so pressing Down Arrow does nothing. Please add an onKeyDown handler through the existing disabled guard (reusing the current open path), define and test where focus goes on keyboard open, and add a focused test proving aria-expanded becomes true (plus disabled/already-open cases).

Enter/Space and click still work, and no visual or prop API changes are involved.

[Automated review]

No conflicts. Auto-merged .github/a11y-baseline.json,
DateRangeInput.tsx, DateRangeInput.doc.mjs and DateRangeInput.test.tsx;
the PR's role="combobox" now sits next to upstream's
aria-required={isEffectivelyRequired ...} on the trigger.
The trigger is exposed as role="combobox" but had no keyboard path to
open it besides Enter/Space. Match DateInput: ArrowDown (and
Alt+ArrowDown) on the closed trigger calls the existing handleToggle and
prevents the default page scroll.

- F1: add handleTriggerKeyDown on the trigger. It is gated on
  !popover.isOpen so ArrowDown never closes an open popover, and it
  reuses handleToggle so the isEffectivelyDisabled guard (isDisabled,
  isLoading, pending changeAction) blocks it exactly like click/Enter.
  Doc anatomy and the changeset now mention Down Arrow.
- F2: focus moves into the dialog, as it does on click. No
  skipAutoFocus: DateInput keeps focus in its text field so typing can
  continue, but this trigger is select-only. Pinned by a test asserting
  document.activeElement is inside the dialog after ArrowDown.
- F3: tests for ArrowDown open + focus in dialog, Alt+ArrowDown,
  preventDefault, ArrowDown while already open, isLoading, and ArrowDown
  on the focusable aria-disabled (disabledMessage) trigger. The first
  three failed before the fix (aria-expanded stayed "false"; keydown was
  not default-prevented). Mutation-checked: dropping the isOpen gate
  fails the already-open test; bypassing handleToggle's guard fails the
  isLoading and disabledMessage tests.
@AKnassa

AKnassa commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @cixzhang, and sorry for the slow reply to your check-in. I'd like to continue with this one. Pushed at d16d7b6, with main merged in first (4db85f2, no conflicts; role="combobox" now sits next to main's aria-required logic on the trigger).

  • Down Arrow opens the picker: when the popup is closed, ArrowDown and Alt+ArrowDown on the trigger call preventDefault() and then the existing handleToggle. That means the same disabled/loading guard as click and Enter/Space applies, and the page doesn't scroll. The doc anatomy and the changeset now mention Down Arrow. (d16d7b6)
  • Where focus goes: into the dialog, the same as a click. DateInput uses skipAutoFocus because its combobox is a text field the user may still be typing in. This trigger is a select-only button with nothing to type into, so I didn't carry that over. A test checks that focus ends up inside the dialog. (d16d7b6)
  • Tests: aria-expanded goes to "true" on ArrowDown, Alt+ArrowDown opens it, the keydown is default-prevented, ArrowDown while already open keeps it open, and ArrowDown is blocked while loading and on the focusable disabledMessage (aria-disabled) trigger. (d16d7b6)

If you'd rather keep focus on the trigger, tell me and I'll switch it. I still need to update the PR description for the Down Arrow change and fix the stale #4074 reference in "Not in 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 now looks ready. Exposing the trigger as a combobox (matching DateInput/DateTimeInput) is the right fix for the critical aria-required axe violation, and the baseline removal, name-pinned tests, and changeset note are clear.

The keyboard gap from the previous round is addressed: ArrowDown and Alt+ArrowDown on the closed trigger open the picker through the same disabled/loading guard as click, the page no longer scrolls on that key, focus moves into the dialog as it does on click (a sensible choice for a select-only trigger), and ArrowDown stays blocked while loading or on a disabled-with-reason trigger. The new tests cover each of those cases, including aria-expanded becoming true and focus ending up inside the dialog.

No visual or prop API changes are involved; the only consumer-facing note is the one already in the changeset — role-based queries for the trigger move from button to combobox.

[Automated review]

Upstream added two DateRangeEditor tests after this
branch started ("renders an absolute-to-now range without changing the
filter" and "renders a relative-to-now range without changing the
filter") that locate the DateRangeInput trigger with
getByRole('button', {name: /^date range:/i}). This PR intentionally
exposes that trigger as role="combobox" (matching DateInput and
DateTimeInput), so both queries failed in CI test-ui with "Unable to
find an accessible element with the role "button"". Switch the two
queries to role "combobox" with the same name matcher; each test's
intent (formatted range text, no onChange) is unchanged.

Red: 2 failed | 20 passed in PowerSearchValueEditor.test.tsx before the
change. Green: all 9 PowerSearch suites plus DateRangeInput and
useInputStatusIcon pass (11 files, 310 tests). A repo-wide search found
no other role=button query, play function, Playwright spec or a11y
baseline entry that targets this trigger.
@AKnassa

AKnassa commented Sep 26, 2026

Copy link
Copy Markdown
Contributor Author

Pushed 784dad1 to fix the red test-ui on the previous head. Two PowerSearch DateRangeEditor tests that landed on main after this branch started look up the date-range trigger as a button. This PR deliberately exposes it as a combobox, like DateInput and DateTimeInput, so I switched those two queries to combobox with the same name matcher. The PowerSearch and DateRangeInput suites pass, and nothing else in the repo relies on the old role.

@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 now looks ready. Exposing the trigger as a combobox (matching DateInput/DateTimeInput) is the right fix for the critical aria-required axe violation, and the baseline removal, name-pinned tests, and changeset note are clear.

The keyboard gap from the previous round is addressed: ArrowDown and Alt+ArrowDown on the closed trigger open the picker through the same disabled/loading guard as click, the page no longer scrolls on that key, focus moves into the dialog as it does on click, and ArrowDown stays blocked while loading or on a disabled-with-reason trigger. The new tests cover each of those cases, including aria-expanded becoming true and focus ending up inside the dialog.

This revision also fixes the PowerSearch fallout: the two DateRangeEditor tests that landed on main querying the trigger as a button now query it as a combobox with the same name matcher and unchanged assertions.

No visual or prop API changes are involved; the only consumer-facing note is the one already in the changeset — role-based queries for the trigger move from button to combobox.

[Automated review]

@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 for following through on the Down Arrow behaviour; it works as described on this branch. Approval now needs an engineering owner to settle the governing spec for this addition: whether the DateRangeInput trigger adopts the combobox pattern (role, Down Arrow and Alt+Down Arrow, focus moving into the calendar) and records it in the component's spec, now that main (#7297) has fixed the same aria-allowed-attr entry by keeping the trigger a button with a hidden "Required" description. An engineering owner records that decision by commenting /approve-spec 784dad1cdc3e0f1607ef8dc6e824eebd9022ac5c on this pull request, and the author may do so if they are an engineering owner. If the combobox stays, the branch also needs a rebase, because it no longer merges cleanly into main:

  • DateRangeInput.tsx and DateRangeInput.test.tsx conflict, and three tests on main still look the trigger up as a button.
  • The changeset's "so aria-required is valid" no longer holds, since main removed aria-required from the trigger.
  • The new onKeyDown needs to compose with a caller's onKeyDown, the way onClick already does on main.

[Automated review]

'@astryxdesign/core': patch
---

[fix] DateRangeInput: expose the trigger as `role="combobox"` (matching DateInput/DateTimeInput) so `aria-required` is valid — it is not allowed on `role=button` (axe aria-allowed-attr, critical). Tests locating the trigger via `getByRole('button', {name})` must switch to `getByRole('combobox')`. Down Arrow (and Alt+Down Arrow) on the trigger now opens the picker, matching DateInput.

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.

On main, #7297 already removed aria-required from this trigger (required state is now a visually hidden description), so after a rebase this reason no longer holds. If the combobox stays, the note should describe the role and Down Arrow change and the accessibility target it serves instead.

type="button"
// Select-only combobox, matching DateInput/DateTimeInput: makes
// aria-required/aria-invalid valid here (not allowed on role=button).
role="combobox"

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.

main cleared the same axe entry in #7297 by keeping this a <button>. Whether the trigger adopts the combobox pattern is an owner decision; if it does, component:DateRangeInput needs to name the adopted parts (spec:AST-020 FR2 and FR15), as component:DateInput AR2 does for DateInput.

// aria-required/aria-invalid valid here (not allowed on role=button).
role="combobox"
onClick={handleToggle}
onKeyDown={handleTriggerKeyDown}

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.

After a rebase, main spreads caller DOM props onto this trigger and chains onClick with chainEventHandlers. This onKeyDown would replace a caller's onKeyDown; compose it the same way, component first (chainEventHandlers(handleTriggerKeyDown, onKeyDownProp)), as input-fields FR10 requires.

@cixzhang

cixzhang commented Nov 8, 2026

Copy link
Copy Markdown
Contributor

(Posted by Cindy's agent.) Thank you, @AKnassa! Your problem report and implementation evidence fed directly into the DateRangeInput repair that shipped in #7297, which credits this PR. Closing this one since that change covers it.

@cixzhang cixzhang closed this Nov 8, 2026
@github-actions
github-actions Bot deleted the rocky/issue-4681-aria-allowed-attr branch November 9, 2026 15:10

This branch was successfully deployed

1 active deployment
Preview — 784dad1c Deployed Sep 26, 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.

2 participants