-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[docs] Create Pickers masked field recipe #13515
[docs] Create Pickers masked field recipe #13515
Conversation
Deploy preview: https://deploy-preview-13515--material-ui-x.netlify.app/ Updated pages: |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a single comment on the cursor positioning. LGTM otherwise!
import { useValidation, validateDate } from '@mui/x-date-pickers/validation'; | ||
|
||
const MASK_USER_INPUT_SYMBOL = '_'; | ||
const ACCEPT_REGEX = /[\d]/gi; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: not so sure about this ... i
definitely isn't needed, but are you intending to only check for a single digit here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept the regexp that we used in v5.
This code came from the lab and I never really touched it a lot to be honested 😆
But we don't have only digits, we have letters, at least for the meridiem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh right ... we could potentially improve this then and use a different regex to exclude anything else: [\d]|(a|p)m
nextMaskChar && | ||
nextMaskChar !== MASK_USER_INPUT_SYMBOL | ||
) { | ||
// when cursor at the end of mask part (e.g. month) prerender next symbol "21" -> "21/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we also move the cursor to behind the '/'?
Right now it looks like this: 21|/
, but preferably it would do this instead: 21/|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In v5 the cursor was before the /
I do agree that having it after would be better, but I did not find a solution to do it 😬
You can play with the original behavior here: https://v5.mui.com/x/react-date-pickers/date-picker/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, i thought so ... its not blocking IMO
Co-authored-by: Michel Engelen <[email protected]> Signed-off-by: Flavien DELANGLE <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this works without problems in its current state i won't block it with nitty stuff! :P
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tiny copyedits here, otherwise text looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. 👍
This is a really great improvement for users desiring the "old" behavior back. 💯
Should we cherry-pick it to v7? 🤔
docs/data/date-pickers/custom-field/custom-behavior/MaskedMaterialTextField.tsx
Outdated
Show resolved
Hide resolved
docs/data/date-pickers/custom-field/custom-behavior/MaskedMaterialTextField.tsx
Outdated
Show resolved
Hide resolved
I'd say no 👼 |
Closes #14494
Follow up on #14606
Demo preview
Extracted PRs
onError
JSDoc #14492