fix(core): announce typed-invalid state in TimeInput#3718
Merged
Conversation
|
@bhamodi is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
ee44f62 to
921a34e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
packages/core/src/TimeInput/TimeInput.tsxcomputesisInputValid(lines 440-451) — false when the typed value failsparseTimeInputor falls outsidemin/max— but before this change used it only for the red-border style (!isInputValid && styles.inputInvalid). The screen-reader signals were missing:aria-invalidwas gated solely onstatus?.type === 'error'(line 638), so a typed out-of-range time never setaria-invalid.Because the value silently reverts on blur, a screen-reader user got no feedback that their entry was invalid — only sighted users saw the red border. This is a WCAG 3.3.1 (Error Identification) gap.
Every sibling typed-format input already handles this the same way — DateInput (
aria-invalidat DateInput.tsx:613-615, alert at 633-635), NumberInput (NumberInput.tsx:643-644, 659-661), and DateTimeInput (DateTimeInput.tsx:1006-1008) — so TimeInput was the lone inconsistency. This fix brings it to parity.Changes
packages/core/src/TimeInput/TimeInput.tsx: OR the parsed-invalid flag intoaria-invalid(status?.type === 'error' || !isInputValid) and add aVisuallyHiddenassertive live region announcing "Invalid time" while the typed input is invalid, mirroring DateInput.packages/core/src/TimeInput/TimeInput.test.tsx: added 4 tests —aria-invalid="true"on out-of-range typed input, noaria-invalidon valid input, analertannouncing "Invalid time" when invalid, and an empty alert when valid.Test plan
node_modules/.bin/vitest run --root . packages/core/src/TimeInput— 35 pass (was 31), including the 4 new tests.aria-invalid, alert-message, and empty-alert tests all failed (no alert element existed andaria-invalidwas never set), proving they catch the gap.node_modules/.bin/tsc --project packages/core/tsconfig.json --noEmit— clean.node_modules/.bin/eslint packages/core/src/TimeInput/TimeInput.tsx packages/core/src/TimeInput/TimeInput.test.tsx— clean.Notes
Found during a broader a11y audit of the input components. Scoped to the
aria-invalidchange and the live region plus tests.DateInput.doc.mjsdoesn't document this behavior (and the repocheck:syncpasses), so no doc change was needed to stay in parity with the siblings.