fix(date-field): open DatePicker calendar on the typed/selected date - #574
Merged
Merged
Conversation
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>
Contributor
Code Metrics Report
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%)
Reported by octocov |
IzumiSy
approved these changes
Oct 6, 2026
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
Typing a date into an empty
DatePickerand pressing Alt+↓ opened the calendar on today's month, so →+Enter picked tomorrow instead of 21 Dec.useCalendarStatesets 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 newhandleOpenChangemoves the calendar to the current value, or today, on every open. It covers both the trigger click and Alt+↓. The date still goes throughsetFocusedDate, so it stays withinminValue/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.Verification
Local: fmt, lint, type-check, the full test suite (1827 core tests) and
docs:checkall 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