Skip to content

Commit

Permalink
fix(clerk-js): Clear feedback when undefined is passed to setError (
Browse files Browse the repository at this point in the history
#2399) (#2409)

We still have a lot of places in clerk-js where we call `setError(undefined)` instead of `clearFeedback`

(cherry picked from commit bf09d18)
  • Loading branch information
panteliselef authored Dec 19, 2023
1 parent 4d5cae2 commit 98f8ec6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-doors-smile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clerk/clerk-js': patch
---

Bug fix: Clear feedback of input field if `setError` is called with undefined.
2 changes: 2 additions & 0 deletions packages/clerk-js/src/ui/utils/useFormControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export const useFormControl = <Id extends string>(
const setError: FormControlState['setError'] = error => {
if (error) {
setFeedback({ message: translateError(error), type: 'error' });
} else {
clearFeedback();
}
};
const setSuccess: FormControlState['setSuccess'] = message => {
Expand Down

0 comments on commit 98f8ec6

Please sign in to comment.