-
Notifications
You must be signed in to change notification settings - Fork 4k
[fix] DateInput: normalize selected dates to start-of-day to honor max #12295
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🎉 Snyk checks have passed. No issues have been found so far.✅ security/snyk check is complete. No issues have been found. (View Details) ✅ license/snyk check is complete. No issues have been found. (View Details) |
✅ PR preview is ready!
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes a date validation issue in the DateInput component where BaseWeb's quick select feature returns Date objects anchored at midday (12:00) while min/max bounds are set to midnight, causing same-day end dates to be incorrectly flagged as exceeding the maximum allowed date.
Key changes:
- Date normalization: Added
normalizeToStartOfDay()function to ensure all selected dates are set to 00:00 before validation - Validation updates: Modified both
handleChangeandupdateWidgetMgrStateto normalize dates before validation - Test coverage: Added comprehensive unit test with time mocking to verify quick select ranges ending "today" are accepted without errors
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
frontend/lib/src/components/widgets/DateInput/DateInput.tsx |
Added date normalization logic to fix midday vs midnight validation issues |
frontend/lib/src/components/widgets/DateInput/DateInput.test.tsx |
Added test case with Date/moment mocking to verify quick select behavior |
lukasmasuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Describe your changes
00:00inhandleChangebefore validation and state updates.updateWidgetMgrStatebefore validation.maxset to today and no error icon is shown.moment.nowandDate, avoiding fake timers that interfere with BaseWeb popovers.GitHub Issue Link (if applicable)
Fixes #12293
Ref #10166, #10764
Testing Plan
Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.