-
Notifications
You must be signed in to change notification settings - Fork 13.5k
bug: ion-datetime not accepting initial values across months when using with multiple option #29094
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
Comments
@thetaPC I found that this issue is mainly due to 1 check that is present in the line
There can be 2 possible solutions to this:
|
Thank you for the issue! This is happening to all packages. After reviewing, this is the expected outcome when there are multiple values with different months. The reason behind this is that we chose not to guess which date the developer wants to show, so the default date shown is May 2021. After talking with the team, we've decided to change it so that it shows just one of the values instead. When those changes are made, this issue will be updated to inform you of its release. |
I agree about that's not possible to auto jump a specific day if there are dates in different months and possible years too. But as devs, we need to have some way to determine this, it could be an initial prop indicating the initial month-year or at least expose the method to navigate to a specific month-year. That could be a real quick solution. Is there any other workaround to navigate to a specific month and year programatically or using a prop?
|
Issue number: resolves #29094 --------- <!-- 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 assigning multiple selected dates that span different months, the date time will not set the correct working parts and instead fallback to the default date: May 28, 2021. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> When opening the datetime with multiple dates selected, the calendar will animate to the last value in the array of selected dates. If the datetime is collapsed, body is not visible, is not a grid view or the user has made a selection of a new date, the calendar will not animate and instead will set the working parts to the current value selected (latest/last value). ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change: 1. Describe the impact and migration path for existing applications below. 2. Update the BREAKING.md file with the breaking change. 3. Add "BREAKING CHANGE: [...]" to the commit description when merging. See https://github.com/ionic-team/ionic-framework/blob/main/docs/CONTRIBUTING.md#footer for more information. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> Internally we discussed setting the month view to the first value in the array. Upon further investigation I determined this is not the expected behavior. When a user interacts with multiple date selection, the most recent selection (their active view) is the **last** value in the array. Animating or updating the working parts to the first value in the array would result in the calendar month jumping after every selection. Using the last index of the array results in no odd jumps in the experience. If a developer wishes to configure this behavior, they can change the order of the values in the value assigned to the datetime (to cause a specific month/date to be the initial view). Dev build: `8.5.8-dev.11748388365.11ad9dfe` --------- Co-authored-by: Maria Hutt <[email protected]>
Thanks for the issue! This has been resolved via PR #29610 and will be available in an upcoming release of Ionic. |
Prerequisites
Ionic Framework Version
v7.x
Current Behavior
ion-datetime
component in Angular doesn't accept values across different months when using withmultiple="true"
. It works very well when we specify any values from the same month but if we supplyvalue
property across different months then it renders the calendar of 2021. It works in case of React but breaking in Angular. User is able to select the values from the calendar from multiple months but when the saved value or initial value that contains date across months, then it breaks.Expected Behavior
ion-datetime
component should accept values across different months when using withmultiple="true"
with Angular.Steps to Reproduce
This is for Angular example.
example.component.ts
define a property named asselectedDates
and assign the values asselectedDates = ['2024-02-20', '2024-03-05']
. Ensure that one date is fromFebruary
and the other is fromMarch
.example.component.html
file, pass theselectedDates
property to thevalue
attribute.Code Reproduction URL
https://stackblitz.com/edit/angular-qtxwpy?file=src%2Fapp%2Fexample.component.ts
Ionic Info
@angular/animations 17.0.1
@angular/common 17.0.1
@angular/compiler 17.0.1
@angular/core 17.0.1
@angular/forms 17.0.1
@angular/platform-browser 17.0.1
@angular/platform-browser-dynamic 17.1.1
@angular/router 17.0.1
@ionic/angular 7.7.3
@ionic/core 7.7.3
rxjs 7.8.1
tslib 2.6.2
zone.js 0.14.2
Additional Information
No response
The text was updated successfully, but these errors were encountered: