Skip to content
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

[pickers] Infer mask from inputFormat #5060

Merged
merged 11 commits into from
Jun 8, 2022

Conversation

alexfauquette
Copy link
Member

@alexfauquette alexfauquette commented May 31, 2022

Fix #4890
Fix #4756

The idea is that is mask is not defined, we try to infer it from the inputFormat this allows to support at the same time libraries that use uppercase letters for ampm and library using lowercase

To run test, I based this PR on #5055

Changelog

The mask can now be inferred from the inputFormat.
This allows supporting different separators like dd/MM/YYYY, dd-MM-YYYY, dd.MM.YYYY and different orders such as MM-dd-YYYY, YYYY-MM-dd without having to specify the mask prop
To be accepted, the input format needs to b made of digits (months can not be Jan, Fev, ...) and with fix length (January must be 01 and not 1).
You can still use disableMaskedInput to disable this feature and provide mask prop to override the inferred mask.

@mui-bot
Copy link

mui-bot commented May 31, 2022

These are the results for the performance tests:

Test case Unit Min Max Median Mean σ
Filter 100k rows ms 248 400.7 344.4 329.36 57.459
Sort 100k rows ms 422.1 976.8 752 719.36 196.703
Select 100k rows ms 111.2 271.1 171.4 174.82 53.77
Deselect 100k rows ms 113.9 289.6 196.6 193.78 59.3

Generated by 🚫 dangerJS against 673b61f

@alexfauquette alexfauquette changed the title remove fixed workaround [pickers] Infer mask from inputFormat May 31, 2022
Comment on lines -49 to -54
expect(runMaskValidation).toWarnDev(
[
`The mask "${mask}" you passed is not valid for the format used ${format}.`,
`Falling down to uncontrolled no-mask input.`,
].join('\n'),
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the The mask ... you passed because when masked is inferred, it does not make sens to show this error message to the dev

Comment on lines -20 to -25
const maskMap = {
fr: '__/__/____',
en: '__/__/____',
ru: '__.__.____',
de: '__.__.____',
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since default mask is inferred, this can be done

@alexfauquette alexfauquette marked this pull request as ready for review June 7, 2022 09:25
Copy link
Member

@flaviendelangle flaviendelangle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't feel very confident approving this one because it's a very touchy part
But if the test pass for all adapters, I think we can give it a try

@alexfauquette alexfauquette force-pushed the get-mask-from-format branch from 9e2fc26 to 673b61f Compare June 8, 2022 08:52
@alexfauquette alexfauquette merged commit a05b853 into mui:master Jun 8, 2022
@alexfauquette alexfauquette deleted the get-mask-from-format branch June 8, 2022 09:28
@flaviendelangle flaviendelangle mentioned this pull request Jun 9, 2022
joserodolfofreitas pushed a commit to joserodolfofreitas/mui-x that referenced this pull request Jun 13, 2022
alexfauquette added a commit to alexfauquette/mui-x that referenced this pull request Aug 26, 2022
@oliviertassinari oliviertassinari added the component: pickers This is the name of the generic UI component, not the React module! label Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module!
Projects
None yet
4 participants