Skip to content

fix: Constrain day on blur #8385

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

boutahlilsoufiane
Copy link
Contributor

@boutahlilsoufiane boutahlilsoufiane commented Jun 11, 2025

Closes #5965 #3256

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

Copy link
Member

@snowystinger snowystinger left a comment

Choose a reason for hiding this comment

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

Thanks for the interest, it looks like this PR is breaking some tests. It would be nice to see those tests updated here so that we know what changed logically.

I would also expect to see new tests for this to prevent regressions in the future, would you mind adding some? Or, if you think it's too early, a description of how to test the changes as you view them in storybook.

Both of these are good to include so that we can follow your thinking and can discuss any assumptions.

@@ -115,7 +115,7 @@ function balanceDay(date: Mutable<AnyCalendarDate>) {

function constrainMonthDay(date: Mutable<AnyCalendarDate>) {
date.month = Math.max(1, Math.min(date.calendar.getMonthsInYear(date), date.month));
date.day = Math.max(1, Math.min(date.calendar.getDaysInMonth(date), date.day));
date.day = Math.max(1, Math.min(31, date.day));
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the util should be loose on the constraint given the name of the function, instead, wherever it is we need it to be loose, we should do this. This way it's obvious when we are truly constraining to a valid date vs dealing with partial information.

@boutahlilsoufiane
Copy link
Contributor Author

Thanks @snowystinger for taking the time to check this. I’ll finish the work and mention you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Datepicker field - Inconsistency in accepting leap day input via keyboard
2 participants