-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Fix Issue#24491 #24535
Fix Issue#24491 #24535
Conversation
CLA Signature Action: Thank you for your submission, we really appreciate it. We ask that you read and sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just by adding a comment to this pull request with this exact sentence:
By commenting with the above message you are agreeing to the terms of the CLA. Your account will be recorded as agreeing to our CLA so you don't need to sign it again for future contributions to this repository. 0 out of 1 committers have signed the CLA. |
7de33f2
to
0f442a9
Compare
Works great! Non-numerical chars can't be typed into the Amount field. |
ed5705b
to
f0d03a2
Compare
if (['e', 'E', '+', '-'].includes(e.key)) { | ||
const isNumericInput = DECIMAL_INPUT_REGEX.test(e.key) | ||
const isControlKey = | ||
e.key === 'Backspace' || | ||
e.key === 'Tab' || | ||
e.key === 'ArrowLeft' || | ||
e.key === 'ArrowRight' || | ||
e.key === 'Delete' | ||
|
||
// Allow numeric input and decimal point | ||
if (!isNumericInput && !isControlKey) { | ||
e.preventDefault(); | ||
} | ||
}} |
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.
Can we move this to a handler similar to what we do with the other attributes (e.g., onBlur
, onChange
)?
@@ -106,6 +106,21 @@ export default class UnitInput extends PureComponent { | |||
this.props.onChange(value); | |||
}; | |||
|
|||
handleOnKeyDown = (e) => { | |||
const isNumericInput = DECIMAL_INPUT_REGEX.test(e.key) |
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.
Can this.keyPressRegex
be used here instead?
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 does not unfortunately
Signed-off-by: Ethan Wessel <ethan.wessel@consensys.net>
Signed-off-by: Ethan Wessel <ethan.wessel@consensys.net>
Signed-off-by: Ethan Wessel <ethan.wessel@consensys.net>
Signed-off-by: Ethan Wessel <ethan.wessel@consensys.net>
Signed-off-by: Ethan Wessel <ethan.wessel@consensys.net>
Signed-off-by: Ethan Wessel <ethan.wessel@consensys.net>
Signed-off-by: Ethan Wessel <ethan.wessel@consensys.net>
Signed-off-by: Ethan Wessel <ethan.wessel@consensys.net>
d600df4
to
4538212
Compare
Description
Related issues
Fixes: #24491
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist