1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

EIP-1559 - Allow decimals for maxFeePerGas and maxPriorityFeePerGas (#11664)

This commit is contained in:
David Walsh 2021-07-29 10:59:14 -05:00 committed by GitHub
parent 0849738003
commit 15cbe4e9a0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 13 deletions

View File

@ -71,6 +71,7 @@ export default function AdvancedGasControls({
onChange={setGasLimit}
tooltipText={t('editGasLimitTooltip')}
value={gasLimit}
allowDecimals={false}
numeric
autoFocus
/>

View File

@ -27,6 +27,7 @@ export default function FormField({
detailText,
autoFocus,
password,
allowDecimals,
}) {
return (
<div
@ -79,6 +80,7 @@ export default function FormField({
value={value}
detailText={detailText}
autoFocus={autoFocus}
allowDecimals={allowDecimals}
/>
) : (
<input
@ -117,6 +119,7 @@ FormField.propTypes = {
autoFocus: PropTypes.bool,
numeric: PropTypes.bool,
password: PropTypes.bool,
allowDecimals: PropTypes.bool,
};
FormField.defaultProps = {
@ -131,4 +134,5 @@ FormField.defaultProps = {
autoFocus: false,
numeric: false,
password: false,
allowDecimals: true,
};

View File

@ -5,11 +5,12 @@ import Typography from '../typography/typography';
import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system';
export default function NumericInput({
detailText,
value,
detailText = '',
value = 0,
onChange,
error,
autoFocus,
error = '',
autoFocus = false,
allowDecimals = true,
}) {
return (
<div
@ -18,7 +19,14 @@ export default function NumericInput({
<input
type="number"
value={value}
onChange={(e) => 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,
};