Skip to content

fix(date-field): open DatePicker calendar on the typed/selected date - #574

Merged
interacsean merged 2 commits into
mainfrom
fix/date-picker-open-on-value
Oct 6, 2026
Merged

interacsean merged 2 commits into
mainfrom
fix/date-picker-open-on-value

Conversation

@interacsean

Copy link
Copy Markdown
Contributor

Summary

Typing a date into an empty DatePicker and pressing Alt+↓ opened the calendar on today's month, so →+Enter picked tomorrow instead of 21 Dec.

useCalendarState sets the calendar's focused date once, at mount (use-calendar-base-state.ts), and nothing updated it from the field value afterwards. The calendar state also persists while the popover is closed, so reopening landed on today's month or on whatever month was last viewed. The APG date-picker dialog and react-aria instead open on the selected or typed date, falling back to today.

Changes

  • DatePicker: a new handleOpenChange moves the calendar to the current value, or today, on every open. It covers both the trigger click and Alt+↓. The date still goes through setFocusedDate, so it stays within minValue/maxValue.
  • DateRangePicker: it already moved to the start date on open, but only when one was set. It now falls back to a typed end date, then today, instead of a stale last-viewed month.
  • Regression tests: the typed-date + Alt+↓ + →/Enter repro; a controlled value changed while closed, then cleared; and a range with only the end date set. All three fail without the fix.
  • Patch changeset.

Verification

Local: fmt, lint, type-check, the full test suite (1827 core tests) and docs:check all pass. I haven't checked it by hand in the vite showcase; the regression tests replay the repro steps.

Closes tailor-inc/platform-planning#2001

🤖 Generated with Claude Code

The calendar's focused date was seeded once at mount and never followed the
field, so a date typed into the segments opened the popover on today's month
(and arrow + Enter selected relative to it). Re-land the roving focus on the
current value each time the popover opens, falling back to today when empty.

DateRangePicker already re-landed on the start date; it now also falls back
to a typed end date, then today, instead of a stale last-viewed month.

Refs tailor-inc/platform-planning#2001

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@interacsean
interacsean requested a review from a team as a code owner October 5, 2026 03:07
@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (bad3569) #574 (657df5f) +/-
Coverage 87.5% 87.6% +0.0%
Test Execution Time 1m25s 1m49s +24s
Details
  |                     | main (bad3569) | #574 (657df5f) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          87.5% |          87.6% | +0.0% |
  |   Files             |            206 |            206 |     0 |
  |   Lines             |           6084 |           6089 |    +5 |
+ |   Covered           |           5325 |           5334 |    +9 |
- | Test Execution Time |          1m25s |          1m49s |  +24s |

Code coverage of files in pull request scope (94.8% → 96.5%, patch 100.0%)

Files Coverage +/- Patch Coverage Status
packages/core/src/components/calendar/use-calendar-base-state.ts 93.3% +3.7% - affected
packages/core/src/components/date-field/date-field.tsx 100.0% 0.0% 100.0% modified
packages/core/src/components/date-field/date-range-picker.tsx 97.7% +0.0% 100.0% modified

Reported by octocov

@interacsean
interacsean merged commit 430fd6a into main Oct 6, 2026
7 checks passed
@interacsean
interacsean deleted the fix/date-picker-open-on-value branch October 6, 2026 01:25
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.

2 participants