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

Cannot Access "mask" parameters? #505

Closed
kyledgreen opened this issue Jul 5, 2018 · 3 comments
Closed

Cannot Access "mask" parameters? #505

kyledgreen opened this issue Jul 5, 2018 · 3 comments

Comments

@kyledgreen
Copy link

I wanted to use the keepCharPositions prop for the MaskedInput component but I cant figure out how to get the prop down to the component or if it has not been exposed by the DateTextField component yet.
The addtional props could be accepted here: https://github.com/dmtrKovalenko/material-ui-pickers/blob/c02a0f2f68a3c463b3b271378dd80e522363bc72/lib/src/_shared/DateTextField.jsx#L298
or should the props for mask be spread in here?: https://github.com/dmtrKovalenko/material-ui-pickers/blob/c02a0f2f68a3c463b3b271378dd80e522363bc72/lib/src/_shared/DateTextField.jsx#L330

mask documentation: https://github.com/text-mask/text-mask/blob/master/componentDocumentation.md#readme

@rusomirt
Copy link

This method worked for me:

<DatePicker
    ...
    InputProps={{
        inputProps: {
            mask: ...,
            keepCharPositions: true,
        }
    }}
    ...
/>

@kyledgreen
Copy link
Author

kyledgreen commented Jul 12, 2018

That mostly works as a workaround, it overrides the localInputProps.inputProps completely which does some checking of keyboard input:
inputProps: { mask: !keyboard ? null : mask, readOnly: !keyboard, }

but it should work for my use case, thank you.

@nikolayg
Copy link

This no longer works with @material-ui/pickers 3.1.0.

For example, in the following code keepCharPositions does not take effect:

    <KeyboardDatePicker
      autoOk={false}
      variant="inline"
      label={"Test"}
      format={"dd/mm/yyyy"}
      inputValue={"12/12/1900"}
      value={null}
      InputAdornmentProps={{ position: "end" }}
      placeholder={"__/__/____"}
      onChange={(_date, value) => {
        console.log(value);
      }}
      InputProps={{
        inputProps: {
          keepCharPositions: true
        }
      }}
    />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants