-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
base: main
Are you sure you want to change the base?
Conversation
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.
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)); |
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.
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.
Thanks @snowystinger for taking the time to check this. I’ll finish the work and mention you. |
Closes #5965 #3256
✅ Pull Request Checklist: