Commit eb6c4d46 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: do not allow zeroes (#3583)

parent 24734e6a
import styled, { css } from 'lib/theme' import styled, { css } from 'lib/theme'
import { forwardRef, HTMLProps, useCallback } from 'react' import { ChangeEvent, forwardRef, HTMLProps, useCallback } from 'react'
const Input = styled.input` const Input = styled.input`
-webkit-appearance: textfield; -webkit-appearance: textfield;
...@@ -81,13 +81,13 @@ const NumericInput = forwardRef<HTMLInputElement, EnforcedNumericInputProps>(fun ...@@ -81,13 +81,13 @@ const NumericInput = forwardRef<HTMLInputElement, EnforcedNumericInputProps>(fun
ref ref
) { ) {
const validateChange = useCallback( const validateChange = useCallback(
(event) => { (event: ChangeEvent<HTMLInputElement>) => {
const nextInput = enforcer(event.target.value.replace(/,/g, '.')) const nextInput = enforcer(event.target.value.replace(/,/g, '.'))?.replace(/^0+$/, '0')
if (nextInput !== null) { if (nextInput !== undefined) {
onChange(nextInput) onChange(nextInput)
} }
}, },
[onChange, enforcer] [enforcer, onChange]
) )
return ( return (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment