Skip to content

fix(react-calendar-preview): preserve popup focus and compat geometry - #36917

Merged
Dmytro Kirpa (dmytrokirpa) merged 3 commits into
masterfrom
fix/calendar-preview-datepicker-parity
Oct 19, 2026
Merged

Dmytro Kirpa (dmytrokirpa) merged 3 commits into
masterfrom
fix/calendar-preview-datepicker-parity

Conversation

@dmytrokirpa

@dmytrokirpa Dmytro Kirpa (dmytrokirpa) commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Previous Behavior

Calendar picker focus handles cannot forward native focus options. Focusing a picker inside a positioned popup can scroll its host and trigger outside-scroll dismissal.

Calendar Preview's intrinsic root width includes the divider in addition to both picker footprints. Its "Go to today" action also contributes one extra pixel of height compared with Calendar Compat.

Keyboard activation also prevents the native event before notifying selection/action callbacks.
DatePicker then mistakes a valid keyboard selection for a consumer-canceled event.

New Behavior

  • Forward optional native FocusOptions through CalendarDay, CalendarMonth, and CalendarYear focus handles. Calls without options retain browser-default behavior.
  • Match compat root widths for single-picker, side-by-side, and week-number layouts, using shared grid dimensions and token-derived padding.
  • Match compat action height, line-height, and top spacing without DatePicker-specific overrides.
  • Add focus-forwarding tests and 27 exact-geometry browser cases covering five/six-week months, LTR/RTL, overlay navigation, hidden actions, and consumer overrides.
  • Notify keyboard selection/action callbacks before preventing native Enter/Space activation. Add day and month-only regression tests; consumer cancellation remains distinguishable from internal key handling.
  • Update Calendar documentation, API report, and Beachball patch entries.

This is an independent prerequisite for the DatePicker stack beginning at #36914. It is intentionally outside that GitHub PR stack and should merge first.

Validation

Executed in the original workspace before splitting these identical Calendar changes:

  • NX_DAEMON=false yarn nx run-many -t test -p react-calendar-preview react-datepicker-preview --runInBand --skipNxCache — passed: 703 Calendar tests and 111 DatePicker tests.
  • NX_DAEMON=false yarn nx run react-calendar-preview:e2e --excludeTaskDependencies --browser chrome --config retries=0 --spec src/components/Calendar/Calendar.cy.tsx --skipNxCache — passed: 80 browser tests.
  • NX_DAEMON=false yarn nx run react-datepicker-preview:e2e --excludeTaskDependencies --browser chrome --config retries=0 --skipNxCache — passed: 14 browser tests.
  • NX_DAEMON=false yarn nx run-many -t type-check lint -p react-calendar-preview --excludeTaskDependencies --skipNxCache — passed.
  • NX_DAEMON=false yarn nx run-many -t build -p react-calendar-preview react-datepicker-preview --excludeTaskDependencies --parallel=1 --skipNxCache — passed, including API extraction.
  • Browser measurements — all 15 paired DatePicker fixtures have matching compat/preview surface dimensions. Default 442x243, day-only/overlay 222x255, week numbers 472x243.
  • git diff --cached --check — passed.
  • Two package-scoped Beachball patch files generated with yarn beachball change.
  • Follow-up keyboard validation: NX_DAEMON=false yarn nx run react-calendar-preview:test --runInBand --skipNxCache — passed: 706 tests across 19 suites.
  • NX_DAEMON=false yarn nx run react-datepicker-preview:e2e --excludeTaskDependencies --browser chrome --config retries=0 --spec src/components/DatePicker/DatePicker.cy.tsx --skipNxCache — passed: 14 styled DatePicker Chrome tests after the keyboard fix.
  • NX_DAEMON=false yarn nx run react-headless-components-preview:e2e --excludeTaskDependencies --browser chrome --config retries=0 --spec src/components/DatePicker/DatePicker.cy.tsx --skipNxCache — passed: 10 integration tests against the pending headless Calendar and DatePicker branches, including keyboard/day/month-only selection.
  • NX_DAEMON=false yarn nx run react-calendar-preview:lint --command='yarn run -T eslint src/components/Calendar/Calendar.test.tsx src/components/Calendar/useCalendar.tsx src/components/CalendarDay/useCalendarDay.tsx src/components/CalendarDayGridCell/useCalendarDayGridCell.ts src/components/CalendarMonthGridCell/useCalendarMonthGridCell.ts src/components/CalendarYearGridCell/useCalendarYearGridCell.ts' --skipNxCache — passed.
  • A third package-scoped Beachball patch file covers the keyboard callback-order correction.
  • CI screenshot approval and manual screen-reader validation — not run locally.

Related Issue(s)

Forward native FocusOptions through picker handles and restore compat picker and action dimensions. Cover focus forwarding and exact five/six-week LTR/RTL layout geometry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-calendar-preview
Calendar
168.809 kB
47.795 kB
169.495 kB
47.952 kB
686 B
157 B

🤖 This report was generated against 9a3ba2066d273a030b34e1e5e511b8c82be7b95f

@github-actions

Copy link
Copy Markdown

Pull request demo site: URL

…cancellation

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

🟢 Approval recommended

Static review found no blocking implementation defects, with targeted regression coverage supporting the changes; validation was not rerun.

1 open issue
What changed in this PR

Updates Calendar Preview focus handling, sizing, and keyboard callbacks ahead of the DatePicker stack.

Changes:

  • Forward native focus options through picker handles.
  • Match compat layout and action dimensions.
  • Correct keyboard selection callback ordering and add regression coverage, documentation, and patch entries.
File Description
packages/​react-components/​react-calendar-preview/​library/​src/​utils/​calendarDimensions.ts Shared grid widths.
packages/​react-components/​react-calendar-preview/​library/​src/​hooks/​useCalendarPickerStyles.styles.ts Reuse shared width.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarYearGridCell/​useCalendarYearGridCell.ts Reorder selection callback.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarYear/​useCalendarYear.tsx Forward focus options.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarYear/​CalendarYear.types.ts Extend focus handle.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarYear/​CalendarYear.test.tsx Test focus forwarding.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarMonthGridCell/​useCalendarMonthGridCell.ts Reorder selection callback.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarMonth/​useCalendarMonth.tsx Forward focus options.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarMonth/​CalendarMonth.types.ts Extend focus handle.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarMonth/​CalendarMonth.test.tsx Test both picker views.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarDayGridCell/​useCalendarDayGridCell.ts Reorder keyboard selection.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarDay/​useCalendarDayStyles.styles.ts Reuse shared widths.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarDay/​useCalendarDay.tsx Update focus and callback ordering.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarDay/​CalendarDay.types.ts Extend focus handle.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​CalendarDay/​CalendarDay.test.tsx Test focus forwarding.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​Calendar/​useCalendarStyles.styles.ts Align compat geometry.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​Calendar/​useCalendar.tsx Reorder today-action callback.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​Calendar/​Calendar.test.tsx Test keyboard callback ordering.
packages/​react-components/​react-calendar-preview/​library/​src/​components/​Calendar/​Calendar.cy.tsx Add geometry regression cases.
packages/​react-components/​react-calendar-preview/​library/​README.md Document updated behavior.
packages/​react-components/​react-calendar-preview/​library/​etc/​react-calendar-preview.api.md Update public focus signatures.
change/​@fluentui-react-calendar-preview-987737e5-9b81-4989-bd70-c79b4d70225b.json Focus-options patch entry.
change/​@fluentui-react-calendar-preview-55b038b4-d20a-4a69-9030-e18fee6e601d.json Keyboard-ordering patch entry.
change/​@fluentui-react-calendar-preview-32caec0e-a7b4-4fb4-b487-d151db303d1e.json Geometry patch entry.

Review effort: Balanced

Comment thread packages/react-components/react-calendar-preview/library/README.md Outdated

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.

It looks good,
Just need to clean up the copilot suggestion and the change files, otherwise it looks like a nice job tidying up some logic to squash some bugs

Comment thread change/@fluentui-react-calendar-preview-32caec0e-a7b4-4fb4-b487-d151db303d1e.json Outdated
@dmytrokirpa
Dmytro Kirpa (dmytrokirpa) merged commit 2f171ba into master Oct 19, 2026
18 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants