diff --git a/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js b/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js index ba0679dee..23f2e77cb 100644 --- a/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js +++ b/ui/components/app/advanced-gas-controls/advanced-gas-controls.component.js @@ -71,6 +71,7 @@ export default function AdvancedGasControls({ onChange={setGasLimit} tooltipText={t('editGasLimitTooltip')} value={gasLimit} + allowDecimals={false} numeric autoFocus /> diff --git a/ui/components/ui/form-field/form-field.js b/ui/components/ui/form-field/form-field.js index 5a4f97ab2..9152937a6 100644 --- a/ui/components/ui/form-field/form-field.js +++ b/ui/components/ui/form-field/form-field.js @@ -27,6 +27,7 @@ export default function FormField({ detailText, autoFocus, password, + allowDecimals, }) { return (
) : ( onChange?.(parseInt(e.target.value, 10))} + onKeyDown={(e) => { + if (!allowDecimals && e.key === '.') { + e.preventDefault(); + } + }} + onChange={(e) => { + onChange?.(parseFloat(e.target.value, 10)); + }} min="0" autoFocus={autoFocus} /> @@ -37,12 +45,5 @@ NumericInput.propTypes = { onChange: PropTypes.func, error: PropTypes.string, autoFocus: PropTypes.bool, -}; - -NumericInput.defaultProps = { - value: 0, - detailText: '', - onChange: undefined, - error: '', - autoFocus: false, + allowDecimals: PropTypes.bool, };