Skip to content

Commit

Permalink
[pickers] Ignore milliseconds in mask logic (mui#6618)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Oct 25, 2022
1 parent 3d160f7 commit f081ef6
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions packages/x-date-pickers/src/internals/hooks/useMaskedInput.tsx
Expand Up @@ -91,7 +91,13 @@ export const useMaskedInput = <TDate extends unknown>({

const isAcceptedValue = value === null || utils.isValid(value);

if (!localeHasChanged && (!isAcceptedValue || utils.isEqual(innerInputValue, value))) {
const innerEqualsProvided =
innerInputValue === null
? value === null
: value !== null &&
Math.abs(utils.getDiff(innerInputValue, value, 'seconds')) === 0;

if (!localeHasChanged && (!isAcceptedValue || innerEqualsProvided)) {
return;
}

Expand Down Expand Up @@ -124,11 +130,11 @@ export const useMaskedInput = <TDate extends unknown>({
const inputStateArgs = shouldUseMaskedInput
? rifmProps
: {
value: innerDisplayedInputValue,
onChange: (event: React.ChangeEvent<HTMLInputElement>) => {
handleChange(event.currentTarget.value);
},
};
value: innerDisplayedInputValue,
onChange: (event: React.ChangeEvent<HTMLInputElement>) => {
handleChange(event.currentTarget.value);
},
};

return {
label,
Expand Down

0 comments on commit f081ef6

Please sign in to comment.