Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@lukasmasuch
Copy link
Collaborator

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)

Testing Plan

  • Added unit test.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Contributor

snyk-io bot commented Jul 21, 2025

🎉 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)

@github-actions
Copy link
Contributor

github-actions bot commented Jul 21, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-11999/streamlit-1.47.0-py3-none-any.whl
🕹️ Preview app pr-11999.streamlit.app (☁️ Deploy here if not accessible)

@lukasmasuch lukasmasuch added security-assessment-completed Security assessment has been completed for PR change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Jul 21, 2025
@lukasmasuch lukasmasuch requested a review from Copilot July 21, 2025 18:58

This comment was marked as outdated.

@lukasmasuch lukasmasuch requested a review from Copilot July 21, 2025 19:02
Copy link
Contributor

Copilot AI left a 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 enableQuickSelect value instead of just checking element.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

Comment on lines +135 to +137
const twoYearsAgo = moment().subtract(2, "years").toDate()
return minDate < twoYearsAgo
}, [element.isRange, minDate])
Copy link
Collaborator Author

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.

@lukasmasuch lukasmasuch merged commit bb7f4b1 into develop Jul 23, 2025
38 checks passed
@lukasmasuch lukasmasuch deleted the fix/date-input-quick-select branch July 23, 2025 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:bugfix PR contains bug fix implementation impact:users PR changes affect end users security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quick select for st.date_input allows invalid selections

3 participants