1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

Improve slippage input validation in Swaps (#13914)

* Improve client-side validation for the slippage input

* Improve validation of the slippage input field

* Use Number instead of toNumber
This commit is contained in:
Daniel 2022-03-14 15:41:03 +01:00 committed by GitHub
parent 466379b325
commit 5aff1863ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -166,11 +166,15 @@ export default function SlippageButtons({
>
<input
onChange={(event) => {
setCustomValue(event.target.value);
onSelect(Number(event.target.value));
const { value } = event.target;
const isValueNumeric = !isNaN(Number(value));
if (isValueNumeric) {
setCustomValue(value);
onSelect(Number(value));
}
}}
type="number"
step="0.1"
type="text"
maxLength="4"
ref={setInputRef}
onBlur={() => {
setEnteringCustomValue(false);