Skip to content

fix: preserve focus after controlled month changes - #3010

Merged
gpbl merged 2 commits into
mainfrom
fix/controlled-month-focus
Aug 26, 2026
Merged

fix: preserve focus after controlled month changes#3010
gpbl merged 2 commits into
mainfrom
fix/controlled-month-focus

Conversation

@gpbl

@gpbl gpbl commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Context

Changing the controlled month and selected values while a day has focus replaces that day button. Focus currently falls back to the document body and keyboard navigation stops.

Closes #3009.

Analysis

useFocus retains the CalendarDay from the previously visible month. Although calculateFocusTarget identifies the selected day in the new month, that target is only used for the roving tab index and is never promoted to the focused state. The replacement DayButton therefore never receives the focused modifier that triggers DOM focus.

Solution

  • Reconcile a stale focused day with the calculated focus target when the previous day is no longer displayed.
  • Leave focus unchanged when it has already moved outside the day grid.
  • Add source and consumer-level regression coverage for both focus paths.
  • Add an interactive ControlledMonthFocus example to the examples app.
  • Add a patch changeset for react-day-picker and @daypicker/react.
  • Validate all Jest projects, TypeScript, Biome, the examples-app production build, and the changeset release plan.

@changeset-bot

changeset-bot Bot commented Aug 22, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a8d8470

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
react-day-picker Patch
@daypicker/react Patch
@daypicker/buddhist Patch
@daypicker/ethiopic Patch
@daypicker/hebrew Patch
@daypicker/hijri Patch
@daypicker/persian Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gpbl
gpbl requested a review from rodgobbi August 22, 2026 07:48
@gpbl
gpbl merged commit 19033b4 into main Aug 26, 2026
11 checks passed
@gpbl
gpbl deleted the fix/controlled-month-focus branch August 26, 2026 07:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Focus is lost when a controlled month change removes the focused day

1 participant