diff --git a/src/components/common/NumberField/index.tsx b/src/components/common/NumberField/index.tsx new file mode 100644 index 0000000000..d5daa5c053 --- /dev/null +++ b/src/components/common/NumberField/index.tsx @@ -0,0 +1,31 @@ +import { TextField } from '@mui/material' +import { forwardRef, useRef } from 'react' +import type { TextFieldProps } from '@mui/material' +import type { ReactElement } from 'react' + +const NumberField = forwardRef(({ inputProps, ...props }, ref): ReactElement => { + const inputRef = useRef() + + const handleBlur = () => { + inputRef.current?.blur() + } + + return ( + + ) +}) + +NumberField.displayName = 'NumberField' + +export default NumberField diff --git a/src/components/settings/SpendingLimits/NewSpendingLimit/steps/SpendingLimitForm.tsx b/src/components/settings/SpendingLimits/NewSpendingLimit/steps/SpendingLimitForm.tsx index f2dbc80e77..9dc173f5da 100644 --- a/src/components/settings/SpendingLimits/NewSpendingLimit/steps/SpendingLimitForm.tsx +++ b/src/components/settings/SpendingLimits/NewSpendingLimit/steps/SpendingLimitForm.tsx @@ -8,7 +8,6 @@ import { MenuItem, Select, Switch, - TextField, Typography, RadioGroup, FormControlLabel, @@ -23,6 +22,7 @@ import useChainId from '@/hooks/useChainId' import { getResetTimeOptions } from '@/components/transactions/TxDetails/TxData/SpendingLimits' import { defaultAbiCoder } from '@ethersproject/abi' import { parseUnits } from 'ethers/lib/utils' +import NumberField from '@/components/common/NumberField' export type NewSpendingLimitData = { beneficiary: string @@ -107,10 +107,9 @@ export const SpendingLimitForm = ({ data, onSubmit }: Props) => { - void }): ReactElem }, }} render={({ field, fieldState }) => ( - void }): ReactElem }, }} render={({ field, fieldState }) => ( - { {!!params.safeTxGas && ( - { {/* User nonce */} - @@ -150,10 +147,9 @@ const AdvancedParamsForm = ({ params, ...props }: AdvancedParamsFormProps) => { {props.isEIP1559 && ( - { - diff --git a/src/components/tx/AdvancedParams/GasLimitInput.tsx b/src/components/tx/AdvancedParams/GasLimitInput.tsx index 9a25043d0f..fd83f8ea3f 100644 --- a/src/components/tx/AdvancedParams/GasLimitInput.tsx +++ b/src/components/tx/AdvancedParams/GasLimitInput.tsx @@ -1,8 +1,9 @@ -import { FormControl, IconButton, TextField, Tooltip } from '@mui/material' +import { FormControl, IconButton, Tooltip } from '@mui/material' import RotateLeftIcon from '@mui/icons-material/RotateLeft' import { useFormContext } from 'react-hook-form' import { BASE_TX_GAS } from '@/config/constants' import { AdvancedField } from './types.d' +import NumberField from '@/components/common/NumberField' const GasLimitInput = ({ recommendedGasLimit }: { recommendedGasLimit?: string }) => { const { @@ -31,10 +32,9 @@ const GasLimitInput = ({ recommendedGasLimit }: { recommendedGasLimit?: string } return ( - @@ -48,7 +48,6 @@ const GasLimitInput = ({ recommendedGasLimit }: { recommendedGasLimit?: string } InputLabelProps={{ shrink: currentGasLimit !== undefined, }} - type="number" required {...register(AdvancedField.gasLimit, { required: true, min: BASE_TX_GAS })} /> diff --git a/src/components/tx/NonceForm/index.tsx b/src/components/tx/NonceForm/index.tsx index 393c7a89e3..a38a5b70df 100644 --- a/src/components/tx/NonceForm/index.tsx +++ b/src/components/tx/NonceForm/index.tsx @@ -1,16 +1,17 @@ import { memo, useMemo } from 'react' import type { ReactElement } from 'react' import { useController, useFormContext, useWatch } from 'react-hook-form' -import { Autocomplete, IconButton, InputAdornment, MenuItem, TextField, Tooltip } from '@mui/material' +import { Autocomplete, IconButton, InputAdornment, MenuItem, Tooltip } from '@mui/material' import RotateLeftIcon from '@mui/icons-material/RotateLeft' import useSafeInfo from '@/hooks/useSafeInfo' +import NumberField from '@/components/common/NumberField' import useTxQueue, { useQueuedTxByNonce } from '@/hooks/useTxQueue' import { isMultisigExecutionInfo, isTransactionListItem } from '@/utils/transaction-guards' import { uniqBy } from 'lodash' import { getTransactionType } from '@/hooks/useTransactionType' import useAddressBook from '@/hooks/useAddressBook' -import type { MenuItemProps } from '@mui/material' import { getLatestTransactions } from '@/utils/tx-list' +import type { MenuItemProps } from '@mui/material' type NonceFormProps = { name: string @@ -112,13 +113,11 @@ const NonceForm = ({ name, nonce, recommendedNonce, readonly }: NonceFormProps): }, }} renderInput={(params) => ( - ( @@ -179,10 +179,9 @@ const SendAssetsForm = ({ onSubmit, formData, disableSpendingLimit = false }: Se )} -