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 { forwardRef, HTMLProps, useCallback } from 'react'
import { ChangeEvent, forwardRef, HTMLProps, useCallback } from 'react'
const Input = styled.input`
-webkit-appearance: textfield;
......@@ -81,13 +81,13 @@ const NumericInput = forwardRef<HTMLInputElement, EnforcedNumericInputProps>(fun
ref
) {
const validateChange = useCallback(
(event) => {
const nextInput = enforcer(event.target.value.replace(/,/g, '.'))
if (nextInput !== null) {
(event: ChangeEvent<HTMLInputElement>) => {
const nextInput = enforcer(event.target.value.replace(/,/g, '.'))?.replace(/^0+$/, '0')
if (nextInput !== undefined) {
onChange(nextInput)
}
},
[onChange, enforcer]
[enforcer, onChange]
)
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