fix(datebox): keep optional field valid after backspace clear#307
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 (2)
📝 WalkthroughWalkthroughThis PR addresses the invalid state issue when clearing a non-required ChangesNon-Required Empty Field Validation Fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #307 +/- ##
==========================================
- Coverage 96.95% 93.11% -3.85%
==========================================
Files 70 166 +96
Lines 1542 2756 +1214
Branches 150 405 +255
==========================================
+ Hits 1495 2566 +1071
- Misses 28 98 +70
- Partials 19 92 +73 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Description
Closes #301
When a
LumexDateboxis bound to a nullable type withRequired="false"andClearable="true", pressing Backspace to clear the field puts it into an error state instead of the expected valid empty state.The browser's native
<input type="date">is segmented (year/month/day). Backspacing one segment makes the value serialize to""per the HTML spec, but the input also gainsvalidity.badInput = truewith a non-emptyvalidationMessage("Please enter a valid value."). The component was unconditionally surfacing that native message viaLumexInputFieldBase.SetValidationMessageAsync, so the field flipped to invalid even though the bound value parsed cleanly tonull.What's been done?
LumexInputFieldBase.SetValidationMessageAsync, skip the nativevalidationMessageprobe when the field is non-required and empty — an empty value on an optional field is valid by definition. This also benefitsLumexNumboxandLumexTextbox, which share the same base.ShouldStayValidWhenClearedAndNotRequired) that simulates the browser returning abadInputmessage and asserts the cleared, non-required field stays valid (data-invalid="false") withValue == null.Checklist
Summary by CodeRabbit
Bug Fixes