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

Fix Issue#24491 #24535

Merged
merged 8 commits into from
May 15, 2024
Merged

Fix Issue#24491 #24535

merged 8 commits into from
May 15, 2024

Conversation

ejwessel
Copy link
Contributor

@ejwessel ejwessel commented May 15, 2024

Description

Open in GitHub Codespaces

Related issues

Fixes: #24491

Manual testing steps

  1. Go to this page...

Screenshots/Recordings

Before

After

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've completed the PR template to the best of my ability
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@ejwessel ejwessel requested a review from a team as a code owner May 15, 2024 05:23
Copy link
Contributor

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:

I have read the CLA Document and I hereby sign the CLA

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.
@ejwessel

@sleepytanya
Copy link
Contributor

Works great! Non-numerical chars can't be typed into the Amount field.

@ejwessel ejwessel force-pushed the mb843/issue#24491 branch 2 times, most recently from ed5705b to f0d03a2 Compare May 15, 2024 18:09
Comment on lines 182 to 194
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();
}
}}
Copy link
Contributor

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)
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does not unfortunately

@ejwessel
Copy link
Contributor Author

#24491

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>
@ejwessel ejwessel merged commit 06f1564 into mb843/updates-2 May 15, 2024
5 of 8 checks passed
@ejwessel ejwessel deleted the mb843/issue#24491 branch May 15, 2024 22:28
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants