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
[TextField] type=number missing min, max, step Typescript types #9313
Comments
Does this work? <TextField type="number" inputProps={{ min: "0", max: "10", step: "1" }} /> |
Yes that works. |
…['SelectProps'] Resolves mui#9313.
Good point, I've opened #9321 to fix the typing of |
Example: import * as MaskedInput from 'react-text-mask'
<TextField
InputProps={{
inputComponent: MaskedInput,
}}
inputProps={{
guide: false,
mask,
placeholderChar: '\u2000',
}}
type="tel"
value={value}
/> |
So the alternative to avoiding strongly typed import { InputProps as MuiInputProps } from 'material-ui/Input'
<TextField
InputProps={{
inputComponent: (inputProps: MuiInputProps) => (
<MaskedInput {...inputProps} guide={false} mask={mask} placeholderChar="\u2000" />
),
}}
type="tel"
value={value}
/> @pelotom is filing a new proposal/issue to revisit this API. |
@rosskevin |
This seems like an overly complicated workaround |
It would be better to define these at the TextField level, so that validation can be performed without a bunch of repeated logic everywhere. I'd hate to have to extend TextField every time I want to use it for a number field with min/max/step requirements. |
@pelotom , @oliviertassinari , @rosskevin : If the numbers are entered as input as shown in the image it is easy to bypass the control. Is there a solution? Link: codesandbox |
this doesn't work when you type something. |
How to write float value in TextField as input in material ui component for multiple input field ?? |
@Himanshudabhi34 Can you Please provide more details? What do you mean by float value in textfield? As it already accept. |
Expected Behavior
<TextField type="number" min="0" max="10" step="1" />
should compile with TypescriptCurrent Behavior
Receive following Typescript error for min, similar for max and step:
[ts] Property 'min' does not exist on type 'IntrinsicAttributes & TextFieldProps & { children?: ReactNode; }'.
Your Environment
The text was updated successfully, but these errors were encountered: