Skip to content

fix: preserve date when manually entering the year - #5290

Open
FranklinD10 wants to merge 4 commits into
sws2apps:mainfrom
FranklinD10:fix/manual-date-input-year
Open

fix: preserve date when manually entering the year#5290
FranklinD10 wants to merge 4 commits into
sws2apps:mainfrom
FranklinD10:fix/manual-date-input-year

Conversation

@FranklinD10

Copy link
Copy Markdown

What this fixes

Closes #5072.

When manually typing a date, tabbing into or editing the year field made the whole entry disappear. While the year section is incomplete, MUI emits an Invalid Date, and the picker was forwarding that straight to the parent onChange, which wiped the stored value (this also caused the day/month to reset when editing the year).

The change

In handleValueChange (src/components/date_picker/index.tsx), only call the parent onChange when the value is a complete valid date or the field has been fully cleared (null). Intermediate Invalid Date states are kept local to the field, so partial typing no longer clears anything. The clear button still passes null through as before.

Testing

  • Reproduced with a person's Time away end date and the CO visit date: typing DD, MM, then YYYY no longer clears the field.
  • Fully clearing the field still works.
  • npm run build passes and eslint is clean on the changed file.

Scope is intentionally kept to the disappearing-value bug. The other UX points in the issue (focus retention, widget max-height, end-date-before-start validation, widget opening on the start month) are separate and can be follow-ups.

Typing into the year section produces an intermediate Invalid Date that
the picker was forwarding to the parent, clearing the whole field. Only
propagate onChange for a complete valid date or a cleared field.

Closes sws2apps#5072
@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
staging-organized-app Ready Ready Preview Jul 26, 2026 7:21pm
test-organized-app Ready Ready Preview Jul 26, 2026 7:21pm

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 10845eb4-991f-4c70-9730-c4c8c93813f0

📥 Commits

Reviewing files that changed from the base of the PR and between 3cff27b and 18bdbab.

📒 Files selected for processing (1)
  • src/components/date_picker/index.tsx

Walkthrough

The date picker now prevents invalid intermediate manual entries from reaching the parent, while still propagating fully valid dates and cleared values.

Changes

Date input validation

Layer / File(s) Summary
Guard date change propagation
src/components/date_picker/index.tsx
handleValueChange invokes onChange only for valid Date values or null, excluding invalid intermediate input.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main fix: preserving dates during manual year entry.
Description check ✅ Passed The description matches the change and explains the manual date-entry bug fix.
Linked Issues check ✅ Passed The code prevents intermediate Invalid Date values from reaching the parent, matching #5072's manual YYYY entry fix.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to the date-picker bug and introduces no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@FranklinD10

FranklinD10 commented Jul 14, 2026

Copy link
Copy Markdown
Author

@rhahao @ux-git

@FranklinD10

Copy link
Copy Markdown
Author

@sonarqubecloud

Copy link
Copy Markdown

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.

[FIX] Manual date input fails on YYYY

1 participant