fix(DateField): fixed direct incorrect passing of date values to input element#2549
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe changes add dynamic HTML input type and value normalization to the DateField component based on inferred date-time granularity. A new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 |
commit: |
|
@rastuhacode This should fix the issue I was describing! Support for the datetime-local type looks right to me. Weird mind meld, I was just about to make a PR for this. Thanks for taking this on! |
|
@rastuhacode I've verified your changes do indeed fix the issue. 🚀 |
|
@kadengriffith thank you for verifying and glad I could help! |
|
Thanks for the PR @rastuhacode . LGTM! |
🔗 Linked issue
#2398
❓ Type of change
📚 Description
Resolves #2398
Problem:
The hidden
<input>insideDateFieldRoot(used by bothDateFieldandDatePicker) had three issues that caused browser console warnings and blocked form submission:type="date"was hardcoded — Whengranularityis set tohour,minute, orsecond, the underlyingDateValueincludes time components. Atype="date"input only acceptsyyyy-MM-dd, so the browser rejected the value and emitted console warnings. Withrequired, this prevented form submission entirely.valueused rawDateValue.toString()— ForCalendarDateTimethis produces2024-01-15T10:30:00, and forZonedDateTimeit includes the timezone (2024-01-15T10:30:00[America/New_York]), neither of which is valid fortype="date".min/maxpassedDateValueobjects directly — HTML attributes expect properly formatted strings.Changes:
normalizeInputValue(date, granularity)utility that formats aDateValueinto the correct string for the resolved input type:yyyy-MM-ddfortype="date"yyyy-MM-ddTHH:mmfortype="datetime-local"(hour/minute)yyyy-MM-ddTHH:mm:ssfortype="datetime-local"(second)DateFieldRoot.vueto use dynamic:type, and formatted strings for:value,:min, and:max.📝 Checklist
Summary by CodeRabbit