-
Notifications
You must be signed in to change notification settings - Fork 4k
Hide quickselect in date_input if min date is more than 2 years ago
#11999
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 modifies the date input widget to conditionally hide the quickselect feature based on the minimum date configuration. The change ensures that quickselect is only enabled for range date inputs when the minimum date is more than 2 years in the past, addressing compatibility issues with configured date constraints.
Key Changes
- Added logic to calculate whether quickselect should be enabled based on minimum date
- Updated the DateInput component to use the calculated
enableQuickSelectvalue instead of just checkingelement.isRange - Added comprehensive test coverage for the new quickselect behavior
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| frontend/lib/src/components/widgets/DateInput/DateInput.tsx | Implements enableQuickSelect logic that checks if minDate is older than 2 years before enabling quickselect |
| frontend/lib/src/components/widgets/DateInput/DateInput.test.tsx | Adds test cases covering quickselect behavior with recent vs old minimum dates |
| const twoYearsAgo = moment().subtract(2, "years").toDate() | ||
| return minDate < twoYearsAgo | ||
| }, [element.isRange, minDate]) |
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.
An alternative here might be to manually configure the quick selection options based on the min value, but since this is a quite minor feature it might not be worth the added effort.
Describe your changes
Quickselect in date input is allowing to go back to up to 2 years. In order to comply with the configured min date, we are only activating quickselect if the min date is at least 2 years ago
GitHub Issue Link (if applicable)
st.date_inputallows invalid selections #11939Testing 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.