Repository navigation
[scheduler] Follow the APG grid pattern for keyboard navigation in the Event Calendar - #24338
Conversation
Deploy previewBundle size
PerformanceNo regressions in 38 benchmarks · precise to ±13.2% (±62.1% at worst) · ran 9m 28s · details Check out the code infra dashboard for more information about this PR. |
…etween its events with the arrow keys
…the time grid, stable tab stop - Let Escape disarm an armed event before it moves focus back to the cell. - Keep the scrollers of the Week and Day views out of the Tab sequence. - Only reset the tab stop of the month view when its days change, and use the first visible day of the month when the 1st is hidden. - Keep the menu anchored to the event when the browser fires contextmenu for the key that opened it, without a flag left behind. - Leave the number of events out of the cell names while loading. - Accept the key in the position of C on non-Latin layouts, and ignore IME composition. - Share the arrow key handling of the cell items with the "+N more" popover. - Fix stale comments and docs, and add the missing tests.
The focused cell state only told each cell to focus itself from an effect. The root now focuses the cell directly, and focusing a cell makes it the tab stop.
flaviendelangle
left a comment
There was a problem hiding this comment.
PR review
Two merge-blocking keyboard regressions. Both reproduce on the PR and pass against the pre-PR production code. Existing targeted suites passed: 177 tests, one skipped. Verification used jsdom.
Bugs (2)
1. 🔴 Tab wrapping prevents reaching the armed event toolbar
Location: CalendarGridRoot.tsx:221
if (event.key === 'Tab') {
offset = event.shiftKey ? -1 : 1;
}On a coarse-pointer device, activating an event arms its toolbar while leaving focus on the event. The new Tab handling cycles through the cell’s items indefinitely, preventing the usual keyboard path to the portaled Edit/Delete buttons. Escape dismisses the toolbar. F2 provides an indirect workaround by exiting the cell while keeping it armed.
Failure scenario: On a touch-capable device with a keyboard, focus an event, press Enter, then Tab. Focus keeps cycling inside the cell instead of reaching Edit.
Fix: Move focus into the toolbar after keyboard activation, or allow Tab to reach its controls while armed. Add a regression covering activation through to the Edit action.
2. 🔴 The creation shortcut consumes text input in custom event content
Location: CalendarGridRoot.tsx:193
if (isCreateEventKey(event)) {
const createEvent = cellsRef.current.get(cell)?.createEvent;
if (createEvent) {
event.preventDefault();
createEvent(event.nativeEvent);
}
}The shortcut uses enteredCellRef for any descendant target. After focusing an event, moving into a nested input leaves that reference set. Typing c therefore prevents text entry and triggers event creation. Previously, keyboard creation required the cell itself to be the event target.
Failure scenario: Render an input inside CalendarGrid.DayEvent, focus the event, then its input, and type cat. The input receives at.
Fix: Exclude inputs, textareas, and editable descendants before processing the creation shortcut. Add a regression verifying that typing preserves the text without creating an event.
Tests (0)
No findings.
Simplifications (0)
No findings.
Docs (0)
No findings.
Verdict
Request changes - preserve keyboard access to the armed toolbar and text entry in custom event content.
🤖 Review generated with Codex
|
Thanks! Both fixed:
|
PR reviewOne merge-blocking keyboard regression remains in the armed toolbar when opened from the "+N more" popover. The earlier grid-toolbar and nested-input fixes work in their covered scenarios. Existing targeted suites passed: 351 tests in Chromium with 3 skipped, and 308 in jsdom with 1 skipped. Bugs (1)1. 🔴 Keep toolbar focus inside the more-events popover's focus scopeLocation: EventToolbar.tsx:133–135 if (target === anchor && !event.shiftKey && tabStop != null) {
event.preventDefault();
tabStop.focus();
}An event in the "+N more" popover can also arm this toolbar on a coarse-pointer device. The popover keeps its MUI modal focus trap active, while I reproduced this in jsdom and Chromium. A Chromium check requiring focus to remain on an actionable item after Tab fails on this head and passes when only Failure scenario: On a touch-capable device with a keyboard, open a month cell's "+N more" popover, focus an event, press Enter to arm it, then Tab. Focus lands on the popover paper instead of Edit, interrupting keyboard navigation through the events. Fix: Coordinate the armed toolbar with the popover's focus trap, for example by rendering the toolbar within its focus scope or suspending enforcement while that toolbar owns focus. Add a regression covering keyboard activation from the more-events popover through Tab to Edit. Tests (0)No findings. Simplifications (0)No findings. Docs (0)No findings. VerdictRequest changes - the new Tab routing loses actionable focus when an event is armed inside the more-events popover. 🤖 Review generated with Codex 🤖 Comment generated with Codex |
|
@flaviendelangle Reproduced and fixed in 9b7c6d0: the popover no longer enforces focus while an event is armed, so Tab reaches the toolbar. Added a regression test covering Enter → Tab → Edit → Tab back from the more-events popover. |
flaviendelangle
left a comment
There was a problem hiding this comment.
PR review
Bugs (7)
1. 🔴 Time-only grids lose their tab stop with default root props
Location: CalendarGridRoot.tsx:86
rowType: rowTypes.find((rowType) => rowType !== 'header') ?? rowTypes[0],The default rowTypes includes day-grid, so the fallback selects that row even when only time columns are rendered. Every actual column receives tabIndex={-1}. Existing TimeColumn and TimeEvent test wrappers use this composition.
Failure scenario: Render <CalendarGrid.Root> containing a time column without overriding rowTypes. Tab skips the entire grid. Reproduced locally.
Fix: Choose a fallback from registered cells and ensure the active tab stop still exists after cells are removed.
2. 🔴 Overflow can redirect focus to the wrong multi-day event segment
Location: calendar-grid-items.ts:42
Array.from(row.querySelectorAll<HTMLElement>(selector)).find(
(candidate) =>
candidate.getAttribute(CALENDAR_GRID_ITEM_ATTRIBUTE) === key && !isHidden(candidate),
)One occurrence can have multiple visible segments in the same week after an overflow day interrupts its bar. Selecting the first visible occurrence key ignores which segment covers the entered cell.
Failure scenario: An event appears Monday, overflows Tuesday, and resurfaces Wednesday through Friday. Entering it from Thursday focuses Monday’s disconnected segment. Its editing surface also anchors there. Reproduced with the real MonthView.
Fix: Resolve the visible segment covering the entered day, rather than the first matching occurrence in the row.
3. 🔴 Replacing a cell’s render element leaves its registration stale
Location: useCalendarGridCellKeyboard.ts:34
const cell = cellRef.current;
// ...
}, [cellRef, coordinates, canCreateEvent, stableCreateEvent, registerCell]);The effect tracks the stable ref object, not the DOM node it contains. Changing the supported render element can replace that node without changing any dependency. The registry retains the detached element.
Failure scenario: Change a cell’s render element while keeping its coordinates. C stops creating events on the replacement, and navigation from neighboring cells targets the detached node. Reproduced locally.
Fix: Register and unregister through a callback ref or a reactive DOM-node value.
4. 🔴 Root keyboard handlers run before consumer cancellation
Location: CalendarGridRoot.tsx:255
props: [
elementProps,
{ /* ... */ onKeyDown: handleKeyDown },
],Base UI merges event handlers in right-to-left order. The built-in handler therefore creates an event or changes focus before the consumer’s handler runs.
Failure scenario: Supply onKeyDown on the root to prevent the C shortcut. Pressing C still creates an event. Reproduced locally; reversing the merge order makes the reproduction pass.
Fix: Put elementProps last, consistent with the cell components.
5. 🔴 Event context menus ignore keyboard cancellation
Location: EventContextMenuContext.tsx:194
childProps.onKeyDown?.(event);
if (!isContextMenuKey(event) || !menuContext || isCoarsePointer()) {The wrapper invokes the child’s handler but opens its menu even when that handler cancels the shortcut.
Failure scenario: An event or its custom content handles Shift+F10 and calls preventDefault(). The scheduler still opens its context menu and takes focus. Reproduced locally; checking cancellation makes the reproduction pass.
Fix: Honor defaultPrevented and the applicable Base UI cancellation flag before opening the menu.
6. 🔴 Toolbar navigation misses events inside shadow roots
Location: EventToolbar.tsx:123
const target = event.target as HTMLElement;
// ...
if (target === anchor && !event.shiftKey && tabStop != null) {This document listener receives the shadow host as event.target, so the anchor comparison fails.
Failure scenario: Inside a shadow root, arm an event and press Tab. Focus follows the grid’s item navigation instead of entering the toolbar.
Fix: Resolve the original target through event.composedPath() or the shared shadow DOM helper. The earlier integration reproduction fails on the PR and passes with this substitution.
7. 🟠 Multi-day keyboard navigation performs quadratic DOM scans
Location: calendar-grid-items.ts:42
Array.from(row.querySelectorAll<HTMLElement>(selector)).find(...)Every hidden copy queries and allocates the entire row again. Successful keyboard movement calls this helper before focus and again during the focus event. Week view has no event-count cap.
Failure scenario: Navigating a week containing hundreds of spanning events stalls. In Chromium, 400 week-long events took a median 41.8 ms per helper call, approximately 84 ms of lookup work per focus move.
Fix: Index visible segments once per invocation and use a Set for deduplication, preserving the segment-aware resolution required by finding 2.
Tests (1)
8. 🟠 Cover creation from a multi-day event’s logical cell
Location: MonthView.test.tsx:1896
await user.keyboard('{Enter}{ArrowDown}');
// ...
await user.keyboard('{Escape}');The multi-day test checks navigation and Escape, while positive C-creation tests focus the cell itself. None protects creation from an item rendered under another day.
Failure scenario: Enter May 6, focus an event physically rendered under May 5, then press C. A regression could create on May 5 or do nothing without failing current tests.
Fix: Extend this scenario to assert through onEventEditingStart that creation starts on May 6.
Simplifications (0)
No findings.
Docs (2)
9. 🟡 Document the armed toolbar’s keyboard behavior
Location: accessibility.md:145
Tab / Shift+Tab | Same as the arrow keys
Escape or F2 | Moves focus back to the cell
Failure scenario: On an armed event, Tab enters the toolbar instead, and Escape first disarms while retaining event focus. Users following this table encounter different behavior.
Fix: Qualify these rows and document toolbar navigation with Left/Right, Home/End, Tab, and Escape.
10. 🟡 Update the time event’s tabindex description
Location: CalendarGridTimeEvent.tsx:151
* Whether the event behaves like a button: `role="button"` and a roving `tabIndex`.Failure scenario: The JSDoc describes the removed behavior. Interactive events now stay at tabIndex={-1}; their containing cell owns the roving tab stop.
Fix: Describe programmatic access through Enter/F2 on the containing column.
Verdict
Request changes because the additional reproductions confirm failures in keyboard entry, focus placement, cell registration, and handler cancellation.
🤖 Review generated with Codex
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
@flaviendelangle All fixed in 1d7a161, with a regression test for each of the three bugs:
I also ran the PR through NVDA 2026.3.1 + Chrome. It found one bug, fixed in 2243e98: the view change made from the view menu was not announced, because the Material UI menu hides the page from assistive technologies while it closes. |
PR reviewOne merge-blocking keyboard-entry issue remains in dynamic compositions of the exported grid primitives. The previous paging findings and docs correction are addressed, and the paging reproductions now pass in jsdom and Chromium. All 18 changed test files pass in jsdom: 484 tests passed, 9 skipped. Bugs (1)1. 🔴 Invalidate the active cell when its row or column disappearsLocation: CalendarGridRoot.tsx:95 const validActiveCell =
activeCell != null && rowTypes.includes(activeCell.rowType) ? activeCell : null;
const tabStop = validActiveCell ?? defaultFocusedCell ?? fallbackTabStop;The guard checks the row type but retains coordinates for a removed row within that type, or a removed column. Those coordinates override the fallback even though no remaining cell matches them. Every remaining cell then has Failure scenario: Render This affects compositions using the published I reproduced both removal cases in jsdom and Chromium. A temporary check that clears active coordinates once their cell is no longer registered makes both cases pass in both environments; the 49 existing grid navigation tests also pass with that check. Fix: Clear or clamp the active coordinates when their cell disappears, validating row and column existence as well as row type after registration settles. Ensure a surviving cell becomes the tab stop. Extend the existing row-removal regression to cover shrinking the row count within one type and removing the active column. Tests (0)No findings. Simplifications (0)No findings. Docs (0)No findings. VerdictRequest changes - removing the active row or column can remove keyboard access to an exported grid composition. 🤖 Comment generated with Codex 🤖 Review generated with Codex |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…d-keyboard # Conflicts: # docs/data/scheduler/localization/data.json # packages/x-scheduler/src/locales/koKR.ts
PR reviewNothing here blocks the merge. The three commits since the last round fix what they target. Three new issues reproduce in jsdom on 9a002f3, and there is one optional simplification. The full Bugs (3)1. 🟠 A Page Up or Page Down that changes nothing still moves focus laterLocation: useCalendarGridPageNavigation.ts:78-84 useIsoLayoutEffect(() => {
const pendingFocus = pendingFocusRef.current;
pendingFocusRef.current = null;
// The focus moved somewhere else in the meantime.
if (pendingFocus == null || !isFocusLostWith(pendingFocus.origin)) {
return;
}Since 1d7a161 removed the timer, the request lives until the days change. If Failure scenario: An app cancels navigation past a max date. In the Month view of May 2025, focus May 15 and press Page Down (canceled). Click a non-focusable area outside the grid, then let the app move to August. Focus jumps to August 15. I reproduced it in jsdom with a controlled Fix: Drop the request when focus leaves the origin cell while that cell is still mounted. For example, a 2. 🟡 The tab stop resets without a change of periodLocation: DayTimeGrid.tsx:430-433, MonthView.tsx:196-204 const defaultFocusedCell = React.useMemo(
() => getDefaultFocusedCell([days], 'time-grid', [nowDayNumber]),
[days, nowDayNumber],
);
Failure scenario: In the Week view of May 4-10, focus Thursday, then pick Tuesday of the same week in the mini calendar, or update a controlled Fix: Reset on a change of the displayed period only, for example on 3. 🟡 The live region announces the Agenda view when its events changeLocation: VisibleRangeAnnouncer.tsx:13-14 const visibleDaysSelector = (state: EventCalendarState) =>
state.viewDefinition?.visibleDaysSelector(state);For the Agenda view this is Failure scenario: Fix: For the Agenda view, announce Tests (0)No findings. Simplifications (1)4. 🟡 Share the hidden date and event count labelLocation: MonthViewCell.tsx:256-263, DayGridCell.tsx:116-123, TimeGridColumn.tsx:136-143 <span
id={labelId}
// The events are unknown while loading.
aria-label={
isLoading ? dateLabel : localeText.gridCellAriaLabel(dateLabel, day.withPosition.length)
}
hidden
/>The three cells repeat the same Failure scenario: A change to the label, such as announcing the loading state, has to land in three files, and missing one makes the Month and Week views name their cells differently. Fix: Move it into one small component, for example Docs (0)No findings. VerdictApprove after nits - nothing blocks the merge, and the leftover Page Down focus request is the one worth fixing first. 🤖 Review generated with Claude Code 🤖 Comment generated with Claude |
|
Feel free to merge after this review |
…the Agenda announcement
…o scheduler-apg-grid-keyboard
|
@flaviendelangle Thanks for the reviews! Everything is addressed:
Each bug has its regression test. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
…d-keyboard # Conflicts: # docs/data/scheduler/localization/data.json # packages/x-scheduler-internals/src/calendar-grid/day-cell/CalendarGridDayCell.tsx # packages/x-scheduler/src/locales/arSD.ts # packages/x-scheduler/src/locales/beBY.ts # packages/x-scheduler/src/locales/bgBG.ts # packages/x-scheduler/src/locales/bnBD.ts # packages/x-scheduler/src/locales/caES.ts # packages/x-scheduler/src/locales/csCZ.ts # packages/x-scheduler/src/locales/daDK.ts # packages/x-scheduler/src/locales/deDE.ts # packages/x-scheduler/src/locales/elGR.ts # packages/x-scheduler/src/locales/esES.ts # packages/x-scheduler/src/locales/faIR.ts # packages/x-scheduler/src/locales/fiFI.ts # packages/x-scheduler/src/locales/frFR.ts # packages/x-scheduler/src/locales/heIL.ts # packages/x-scheduler/src/locales/hrHR.ts # packages/x-scheduler/src/locales/huHU.ts # packages/x-scheduler/src/locales/hyAM.ts # packages/x-scheduler/src/locales/idID.ts # packages/x-scheduler/src/locales/isIS.ts # packages/x-scheduler/src/locales/itIT.ts # packages/x-scheduler/src/locales/jaJP.ts # packages/x-scheduler/src/locales/koKR.ts # packages/x-scheduler/src/locales/nbNO.ts # packages/x-scheduler/src/locales/nlNL.ts # packages/x-scheduler/src/locales/nnNO.ts # packages/x-scheduler/src/locales/plPL.ts # packages/x-scheduler/src/locales/ptBR.ts # packages/x-scheduler/src/locales/ptPT.ts # packages/x-scheduler/src/locales/roRO.ts # packages/x-scheduler/src/locales/ruRU.ts # packages/x-scheduler/src/locales/skSK.ts # packages/x-scheduler/src/locales/svSE.ts # packages/x-scheduler/src/locales/thTH.ts # packages/x-scheduler/src/locales/trTR.ts # packages/x-scheduler/src/locales/ukUA.ts # packages/x-scheduler/src/locales/urPK.ts # packages/x-scheduler/src/locales/viVN.ts # packages/x-scheduler/src/locales/zhCN.ts # packages/x-scheduler/src/locales/zhHK.ts # packages/x-scheduler/src/locales/zhTW.ts # packages/x-scheduler/src/month-view/month-view-row/MonthViewCell.tsx
Closes #24246
The Event Calendar grid followed the Google Calendar model: every cell, header and time column was a tab stop (more than 35 in the month view), and Tab went through the events of each cell. Since the grid exposes
role="grid", this PR moves it to the APG grid pattern, as agreed in #24246.Grid (Month, Week and Day views)
tabIndex={-1}and unreachable).Accessible names and announcements
gridCellAriaLabellocale key).calendarGridAriaLabellocale key), so they can be told apart from the mini calendar.gridHeaderRowLabelandtimeGridLabellocale keys).role="status"region announces the view and its dates when they change, for example "Day view, Monday, July 7, 2025" (newvisibleRangeAnnouncementlocale key). It replaces thearia-liveon the toolbar label, which stayed silent when moving inside the same month.newEventDialogLabellocale key). The drawer of the compact views is now a named dialog too.Events
This applies to every surface using the event context menu (Calendar views, Agenda, "+N more" popover, Event Timeline).
"+N more" popover
Not in this PR
GridContextMenu.Docs
The keyboard and live region sections of the accessibility page are updated.
Testing
Checked with NVDA 2026.3.1 and JAWS 2027 + Chrome on Windows, and with VoiceOver + Chrome on macOS.