-
Notifications
You must be signed in to change notification settings - Fork 0
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
7058-input-validation #988
Conversation
prevent non-numeric values
const [errorMessage, setErrorMessage] = useState<string | null>(null); | ||
|
||
const currencyInputProps = currency |
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.
replaced with MUI's InputAdornment
@gigxz per our discussion I've replaced the custom key handler with react-number-format |
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.
excellent, thanks!!
) : undefined, | ||
...InputProps, | ||
}} | ||
{...(props as any)} |
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.
It seems like NumericFormat actually does handle the typing correctly s-yadav/react-number-format#577
but we run into issues where TextInputProps differ from NumericFormat props. The below keeps typescript happy without the cast:
defaultValue={(defaultValue || '') as string}
type={type as any}
{...props}
(pulling out defaultValue and type from the props object)
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 pushed it since I had it locally anyway: f0721bb lmk what you think!
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.
that's a nice improvement, thanks!
prevent non-numeric values
Description
GH Issue
Related warehouse issue for backend validation
Restrict numeric inputs to numeric characters. Adds
react-number-format
to avoid the complexities of scrubbing user input. Also supports commasType of change
Testing
should exercise the multitude of keyboard entries:
See testing instructions in the wh PR
Checklist before requesting review