Skip to content

[Fix] FE validation for st.date_input#10764

Merged
mayagbarnes merged 13 commits intodevelopfrom
fix-8475
Apr 8, 2025
Merged

[Fix] FE validation for st.date_input#10764
mayagbarnes merged 13 commits intodevelopfrom
fix-8475

Conversation

@mayagbarnes
Copy link
Copy Markdown
Collaborator

@mayagbarnes mayagbarnes commented Mar 13, 2025

Describe your changes

Add FE input validation to st.date_input - render an error tooltip & input in error state when dates outside min/max range, also don't commit a value if not within range.

Error State:

  • Light:
    Screenshot 2025-04-01 at 4 36 56 p m
    Screenshot 2025-04-01 at 4 38 50 p m

  • Dark:
    Screenshot 2025-04-01 at 4 37 07 p m
    Screenshot 2025-04-01 at 4 38 39 p m

GitHub Issue Link (if applicable)

Closes #8475

Testing Plan

  • JS Unit Tests: ✅
  • E2E Tests: ✅
  • Manual Testing: ✅

@mayagbarnes mayagbarnes added security-assessment-completed change:bugfix PR contains bug fix implementation impact:users PR changes affect end users labels Mar 13, 2025
@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Mar 25, 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
Copy Markdown
Contributor

github-actions bot commented Mar 25, 2025

✅ PR preview is ready!

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

@mayagbarnes mayagbarnes changed the title [WIP] [Fix] FE validation for st.date_input [Fix] FE validation for st.date_input Apr 1, 2025
@mayagbarnes mayagbarnes marked this pull request as ready for review April 2, 2025 00:01
Copy link
Copy Markdown
Collaborator

@sfc-gh-bnisco sfc-gh-bnisco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thank you!

@mayagbarnes mayagbarnes merged commit d96f8ce into develop Apr 8, 2025
33 checks passed
@mayagbarnes mayagbarnes deleted the fix-8475 branch April 8, 2025 17:15
sfc-gh-bnisco added a commit that referenced this pull request Aug 22, 2025
#12295)

## Describe your changes

- Problem: BaseWeb’s quick select returns midday-anchored Date objects
(12:00), while our min/max bounds are midnight. Our validation compared
full datetimes, so same-day end dates were flagged as > max.
- Changes:
- Normalize all selected dates to `00:00` in `handleChange` before
validation and state updates.
  - Normalize stored values in `updateWidgetMgrState` before validation.
- Tests:
- Add unit test asserting a quick-select range ending "today" is
accepted with `max` set to today and no error icon is shown.
- Stabilize time by mocking `moment.now` and `Date`, avoiding fake
timers that interfere with BaseWeb popovers.

## GitHub Issue Link (if applicable)

Fixes #12293 
Ref #10166, #10764 

## Testing Plan

- ✅ Unit Tests (JS and/or Python)

---

**Contribution License Agreement**

By submitting this pull request you agree that all contributions to this
project are made under the Apache 2.0 license.
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Date_input allows you to manually enter dates outside the min/max via keyboard input

2 participants