From 5be2b135aaf52f15f191d5e834d7691bcae859cd Mon Sep 17 00:00:00 2001 From: tom Date: Fri, 9 Jun 2023 12:40:23 -0400 Subject: [PATCH] reset form error when button is clicked again --- .../steps/AddressVerificationStepSignature.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/addressVerification/steps/AddressVerificationStepSignature.tsx b/ui/addressVerification/steps/AddressVerificationStepSignature.tsx index 03599cd912..f8bfbe9707 100644 --- a/ui/addressVerification/steps/AddressVerificationStepSignature.tsx +++ b/ui/addressVerification/steps/AddressVerificationStepSignature.tsx @@ -94,20 +94,25 @@ const AddressVerificationStepSignature = ({ address, signingMessage, contractCre }, [ clearErrors ]); const handleOpenWeb3Modal = React.useCallback(() => { + clearErrors('root'); openWeb3Modal(); - }, [ openWeb3Modal ]); + }, [ clearErrors, openWeb3Modal ]); const handleWeb3SignClick = React.useCallback(() => { + clearErrors('root'); + if (!isConnected) { return setError('root', { type: 'manual', message: 'Please connect to your Web3 wallet first' }); } + const message = getValues('message'); signMessage({ message }); - }, [ getValues, signMessage, isConnected, setError ]); + }, [ clearErrors, isConnected, getValues, signMessage, setError ]); const handleManualSignClick = React.useCallback(() => { + clearErrors('root'); onSubmit(); - }, [ onSubmit ]); + }, [ clearErrors, onSubmit ]); const button = (() => { if (signMethod === 'manually') {