mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +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:
parent
466379b325
commit
5aff1863ca
@ -166,11 +166,15 @@ export default function SlippageButtons({
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
onChange={(event) => {
|
onChange={(event) => {
|
||||||
setCustomValue(event.target.value);
|
const { value } = event.target;
|
||||||
onSelect(Number(event.target.value));
|
const isValueNumeric = !isNaN(Number(value));
|
||||||
|
if (isValueNumeric) {
|
||||||
|
setCustomValue(value);
|
||||||
|
onSelect(Number(value));
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
type="number"
|
type="text"
|
||||||
step="0.1"
|
maxLength="4"
|
||||||
ref={setInputRef}
|
ref={setInputRef}
|
||||||
onBlur={() => {
|
onBlur={() => {
|
||||||
setEnteringCustomValue(false);
|
setEnteringCustomValue(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user