Commit a5251f55 authored by Noah Zinsmeister's avatar Noah Zinsmeister

improve stepping behavior

parent 00438bea
...@@ -86,23 +86,23 @@ const StepCounter = ({ ...@@ -86,23 +86,23 @@ const StepCounter = ({
setActive(true) setActive(true)
} }
const handleOnBlur = useCallback(() => {
setUseLocalValue(false)
setActive(false)
onUserInput(localValue) // trigger update on parent value
}, [localValue, onUserInput])
// for button clicks // for button clicks
const handleDecrement = useCallback(() => { const handleDecrement = useCallback(() => {
setLocalValue(decrement()) setUseLocalValue(false)
onUserInput(decrement()) onUserInput(decrement())
}, [decrement, onUserInput]) }, [decrement, onUserInput])
const handleIncrement = useCallback(() => { const handleIncrement = useCallback(() => {
setLocalValue(increment()) setUseLocalValue(false)
onUserInput(increment()) onUserInput(increment())
}, [increment, onUserInput]) }, [increment, onUserInput])
const handleOnBlur = useCallback(() => {
setUseLocalValue(false)
setActive(false)
onUserInput(localValue) // trigger update on parent value
}, [localValue, onUserInput])
useEffect(() => { useEffect(() => {
if (localValue !== value && !useLocalValue) { if (localValue !== value && !useLocalValue) {
setTimeout(() => { setTimeout(() => {
......
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