-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(module:datepicker): for not nullable - on clear set to defaults #1100
fix(module:datepicker): for not nullable - on clear set to defaults #1100
Conversation
I think it's more like a reset method.. |
Yes it is. Basically I retain the original functionality TValue is nullable. But if it is not, then we cannot clear it up - it will take <RangePicker TValue="DateTime[]" DefaultValue="@(new DateTime[] { DateTime.Now.AddYear(-1), DateTime.Now })" /> But I think it is better to set it back to defaults if they exist. Again, this is only if TValue is not nullable and defaults exist. |
What if the value is made minimum when cleared, and the input box is empty? |
I guess this could be done, but I think this might send a wrong message to anyone consuming the date picker. So in this scenario, the date picker would show empty but the values (if |
I'm not sure which is people's want. |
Ok, I understand. I made this change because this is my use case and to me seemed most logical. Please remember that ppl will still have a choice - they will be able to empty completely the fields if they decide to choose |
Wow, thanks 😄 that was faster than I anticipated. |
🤔 This is a ...
💡 Background and solution
Due to the strongly typed nature of C#,
DatePicker
can get either nullable or not nullable dates. When not nullable are used, clearing the values was inputing min value forDateTime
. There is not much we can do about (we can decide to take current date for example). This PR fixes the not nullable clearing scenario when defaults are set - in such case, date picker will assume defaults instead ofDateTime.Min
. For nullable the picker will be cleared.☑️ Self Check before Merge