diff --git a/components/form.js b/components/form.js index 26a956af..221fe52b 100644 --- a/components/form.js +++ b/components/form.js @@ -524,6 +524,11 @@ function InputInner ({ const remaining = maxLength && maxLength - (field.value || '').length + const [showClearButton, setShowClearButton] = useState(clear) + useEffect(() => { + setShowClearButton(clear && field.value) + }, [field.value]) + return ( <> @@ -538,7 +543,7 @@ function InputInner ({ isInvalid={invalid} isValid={showValid && meta.initialValue !== meta.value && meta.touched && !meta.error} /> - {(clear && field.value) && + {showClearButton &&