fix(core): announce Calendar month changes to screen readers#3724
Open
bhamodi wants to merge 1 commit into
Open
fix(core): announce Calendar month changes to screen readers#3724bhamodi wants to merge 1 commit into
bhamodi wants to merge 1 commit into
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. |
15da4e4 to
3c99338
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
Navigating months in
Calendargave screen-reader users no feedback that the grid had changed. The visible month label (Calendar.tsx:447-449) is a plain<span>with no live semantics, and nouseAnnouncecall fired on navigation (navigateMonth,Calendar.tsx:339-359). A keyboard/SR user pressing "Next month" heard only the button name -- the newly shown month was silent.This announces the newly visible month politely (e.g. "March 2026") whenever it changes. Rather than instrument each navigation call site, an effect keys off the existing
monthYearLabelmemo and announces via the repo'suseAnnouncehook (same hookPaginationuses). This reuses the single-/multi-month formatting (no duplicated formatter), fires only when the visible month actually changes, and covers every entry point through one code path:navigateTohandle (CalendarHandle)focusDateprop changeA first-render ref guard prevents announcing the initial month on mount. Because the effect only fires when
monthYearLabelactually changes, selecting a date (which does not move the grid) stays silent, so there is no double-announce. Two-month view announces both months (e.g. "February 2026 – March 2026").Changes
Calendar/Calendar.tsx: importuseAnnounce+useRef; add an effect that announcesmonthYearLabelpolitely on change (skipping first render).Test plan
node_modules/.bin/vitest run --root . packages/core/src/Calendar-- 92 pass (Calendar.test.tsx 51, dayCellUtils.test.ts 41). Seven new tests undermonth change announcements:node_modules/.bin/tsc --project packages/core/tsconfig.json --noEmit-- clean.node_modules/.bin/eslinton changed files -- clean.Notes
Found during a broader a11y audit of core components; scoped to one fix per PR (does not touch aria-current / #3708 or grid semantics). Announcements route through the persistently-mounted polite live region created by
useAnnounce, so they are reliable across screen readers. A controlledfocusDatechange also announces -- this is intentional: the visible grid changed under the user, so it warrants the same polite feedback as clicking a nav button.Calendar.doc.mjswas left unchanged: it has no accessibility/features section and no new props were added, matching how the analogousPaginationannounce behavior is not documented there either.