-
Notifications
You must be signed in to change notification settings - Fork 13.5k
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
bug: ion-datetime is broken/fails when the current value is not defined, the min value is in the future and time format is 12-hour #25296
Comments
Thanks for the issue. Things seem to be working as intended here, though the UX can be improved. In your demo, the current selected date is May 17th (today's date). However, the minimum selectable date is May 20th. This means that there are no times on May 17th that you should be able to select. As a result, no values will appear in the time picker. We are tracking UX improvements for this in #24881. One idea is to have the initial date always be in bounds, even if that means the initial date is not today's date. Does this align with what you are seeing on your end? |
@liamdebeasi thank you very much for a very quick response on this. Please see my comments below
not really. please see below
There is no selected date really since the datetime is provided null as a value. Is it possible to prevent any date to be pre-selected in the datetime component? or may be, the datetime component should pre-select the default date (if none is provided) taking into account the min parameter (so that it is the same or greater then the min date)
This implies that the time part/control should be disabled (and show empty control?) and prevent the user from interacting with it until the user selects the date which is equal or greater than the min date.
This is part of the problem (and I think that this behavior will confuse the end user). The other problem is that the datetime throw an error (see the console) which, I believe, very good reason to consider this as a bug and not as potential UX improvement. To summarize:
|
This is what I was referring to in my previous comment. Right now the default active date in the datetime is today's date. If you provide a
The component's current flow in this scenario needs more design from our end. Having a disabled/empty control seems confusing, and we think it would be better to prevent the user from getting into this state in the first place. This is why I suggested having the pre-selected date always default to an active date that is in range (even if the active date is not today).
I agree that it is confusing. This is why I mentioned #24881 as it is tracking the UX improvements we are looking to do for scenarios like this. The current implementation of the picker requires that there be items to select. Since there are no items to select in the sample app, an error is thrown. It is possible that we will revise this behavior in the future, but at the moment this is the intended behavior. As I mentioned previously, we feel that users should never be put into this state in the first place. Ensuring that the pre-selected date is in range (currently being tracked in #24881) should resolve the following issues:
Does that clarify things? |
A couple other cases that could come up:
I would argue that these are incorrect usages, but it would probably be good to have a console warning. Otherwise, users will get into the same situation described here. |
Yes. This makes sense however there is still an issue. I have to set some value (to make sure that pre-selected value is in the range) to the datetime component which I don't want to. The value should be unset/null unless the user explicitly set it. There is one more minor thing as well. The current and the min date are on the same date but the min time is greater than the current time. The datetime control will show the below (my current time is 5:34 PM and the min time is 7PM of the same date) Thank you very much for all the detailed explanations. |
I recommend opening a separate feature request for this. The current behavior was implemented to align with the native iOS and Android date pickers, so having a separate discussion on this would help us make a more informed decision about which path to take.
This is the same problem as #24881. Ensuring that the I am going to close this in favor of #24881. You can track any progress on that thread. Thanks for all the helpful context! |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out. |
Prerequisites
Ionic Framework Version
Current Behavior
Datetime control show empty time popover and when it is dismissed an error occurs which makes ion-datetime unusable.
Note that the value provided to the control is null and the min property must be in the future. If the min property is in the past then everything works fine.
Expected Behavior
Time part needs to be displayed correctly and no error when it is dismissed/closed
Steps to Reproduce
Note that the popover opened is empty - see below
Note that an error is triggered/thrown - see below
You can also see the problem here https://stackblitz.com/edit/ionic6-angular13-qkrphu?file=src%2Fapp%2Fapp.component.ts
Code Reproduction URL
https://stackblitz.com/edit/ionic6-angular13-qkrphu?file=src%2Fapp%2Fapp.component.ts
Ionic Info
See https://stackblitz.com/edit/ionic6-angular13-qkrphu?file=src%2Fapp%2Fapp.component.ts
Additional Information
This seems to be related to #22756 which has been reported to be fixed.
The text was updated successfully, but these errors were encountered: