From 98f8ec62957a10bd0e8e2b1f136351132d9ac670 Mon Sep 17 00:00:00 2001 From: panteliselef Date: Tue, 19 Dec 2023 17:48:33 +0200 Subject: [PATCH] fix(clerk-js): Clear feedback when `undefined` is passed to `setError` (#2399) (#2409) We still have a lot of places in clerk-js where we call `setError(undefined)` instead of `clearFeedback` (cherry picked from commit bf09d18d6408ac89f8b9207d05e0f3660d27a6cf) --- .changeset/thick-doors-smile.md | 5 +++++ packages/clerk-js/src/ui/utils/useFormControl.ts | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 .changeset/thick-doors-smile.md diff --git a/.changeset/thick-doors-smile.md b/.changeset/thick-doors-smile.md new file mode 100644 index 00000000000..df5423549e4 --- /dev/null +++ b/.changeset/thick-doors-smile.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Bug fix: Clear feedback of input field if `setError` is called with undefined. diff --git a/packages/clerk-js/src/ui/utils/useFormControl.ts b/packages/clerk-js/src/ui/utils/useFormControl.ts index 8e043f77be8..bf3f40e9652 100644 --- a/packages/clerk-js/src/ui/utils/useFormControl.ts +++ b/packages/clerk-js/src/ui/utils/useFormControl.ts @@ -106,6 +106,8 @@ export const useFormControl = ( const setError: FormControlState['setError'] = error => { if (error) { setFeedback({ message: translateError(error), type: 'error' }); + } else { + clearFeedback(); } }; const setSuccess: FormControlState['setSuccess'] = message => {