-
Notifications
You must be signed in to change notification settings - Fork 13.4k
fix(datetime): clamp date between min and max when using month picker #27185
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
|
|
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.
Would it make sense to clamp the date in setActiveParts instead? That would ensure that all dates set are guaranteed to be valid.
|
+1 to what Liam mentioned, I wonder if we can add this logic as part of the |
|
Looks like that works! |
…#27185) <!-- Please refer to our contributing documentation for any questions on submitting a pull request, or let us know here if you need any help: https://ionicframework.com/docs/building/contributing --> <!-- Some docs updates need to be made in the `ionic-docs` repo, in a separate PR. See https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#modifying-documentation for details. --> <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> When using the dropdown month picker, the value is updated when the month is changed, to follow native behavior. However, because only the month is updated (the day remains the same), it's possible for the newly chosen date to fall outside the min/max bounds of the datetime. For example, if you have a datetime with `min="2021-01-15" value="2021-02-01"`, then use the month picker to switch to January, the new value will be `2021-01-01` which is earlier than the `min`. <!-- Issues are required for both bug fixes and features. --> Issue URL: Resolves #27027 ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> When updating the `activeParts` in any scenario, the date to set is now clamped between the max and min. ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. -->
|
It still reproduces, |
|
@madalinporojan2010 Please create a new issue with details: https://github.com/ionic-team/ionic-framework/issues/new/choose |
What is the current behavior?
When using the dropdown month picker, the value is updated when the month is changed, to follow native behavior. However, because only the month is updated (the day remains the same), it's possible for the newly chosen date to fall outside the min/max bounds of the datetime.
For example, if you have a datetime with
min="2021-01-15" value="2021-02-01", then use the month picker to switch to January, the new value will be2021-01-01which is earlier than themin.Issue URL: Resolves #27027
What is the new behavior?
When updating the
activePartsin any scenario, the date to set is now clamped between the max and min.Does this introduce a breaking change?
Other information