-
Notifications
You must be signed in to change notification settings - Fork 832
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
0 is not acceptable by value #1724
Comments
It should not be acceptable. If you need 00:00 time set |
I wonder if we have a prop-type warning in this case. @jiggum Do you have a live reproduction? |
It doesn't. @dmtrKovalenko should we have a custom prop-type to detect this class of issues? Based on the Material-UI stats, 90% of the developers are using the JavaScript demos, in the user-survey, it's 55% without a typing system. |
I wonder that will be to complicated. Because we accept any value that is parsable by any date library. So any value that acceptable by any library is acceptable by us https://dev.material-ui-pickers.dev/getting-started/parsing |
@dmtrKovalenko Ok, it's good to know, so maybe there is no DX improvement opportunity 🤷♂️. |
@dmtrKovalenko Thank you for example. Actually we using |
@jiggum Could you provide a reproduction? What date engine are you using? How does this date engine parse 0? |
@oliviertassinari We only depend on typescript's prop typing and there's no type warning.
We using date-fns.
In formatting part, we using Here is that case |
Probably it’s a pitfall if |
@dmtrKovalenko We have started using ?? in mui/material-ui#20715. But |
Yes we are using it already. But it adds a bit bundle size overhead. |
I think that if @jiggum is able to provide a valid reproduction, we could spend more time on it. Should we consider a version like export function parsePickerInputValue(
now: MaterialUiPickersDate,
utils: MuiPickersAdapter,
{ value, defaultHighlight }: Pick<BasePickerProps, 'value' | 'defaultHighlight'>
): MaterialUiPickersDate | null {
return [value, defaultHighlight, now].reduce((acc, item) => {
const candidate = utils.date(item);
if (!acc && utils.isValid(candidate)) {
return candidate;
}
return acc;
}, null);
} instead of export function parsePickerInputValue(
now: MaterialUiPickersDate,
utils: MuiPickersAdapter,
{ value, defaultHighlight }: Pick<BasePickerProps, 'value' | 'defaultHighlight'>
): MaterialUiPickersDate | null {
const parsedValue = utils.date(value || defaultHighlight || now);
return parsedValue && utils.isValid(parsedValue) ? parsedValue : now;
} ? |
@oliviertassinari Is reproduction means something like this? |
@jiggum Almost, here is what I was looking for https://codesandbox.io/s/material-ui-date-picker-gk7d0 (v4.0.0-alpha.5) :). The input value is correct, but the displayed value in the popup is wrong. |
Environment
Steps to reproduce
Using TimePicker with value of
0
Expected behavior
Picker should use value of 0
Actual behavior
Using time of now
Description
I think the below line is omitting the value of 0
https://github.com/mui-org/material-ui-pickers/blob/next/lib/src/_helpers/date-utils.ts#L106
The text was updated successfully, but these errors were encountered: