fix: preserve date when manually entering the year - #5290
Conversation
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
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe date picker now prevents invalid intermediate manual entries from reaching the parent, while still propagating fully valid dates and cleared values. ChangesDate input validation
Estimated code review effort: 1 (Trivial) | ~5 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@fatmarker can you test this now works in https://staging-organized-app-git-fork-franklind10-fix-a2c43c-sws2apps.vercel.app/ |
|



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 parentonChange, 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 parentonChangewhen the value is a complete valid date or the field has been fully cleared (null). IntermediateInvalid Datestates are kept local to the field, so partial typing no longer clears anything. The clear button still passesnullthrough as before.Testing
npm run buildpasses andeslintis 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.