Skip to content

Commit

Permalink
set error message to null instead of empty string when clearing the e…
Browse files Browse the repository at this point in the history
…rror
  • Loading branch information
beaesguerra committed Nov 6, 2024
1 parent 116ce7e commit d2aeaf8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,7 @@ describe("TextArea", () => {
expect(field).toHaveAttribute("aria-invalid", "false");
});

it("should call onValidate with an empty string when the user changes the value after there was an error", async () => {
it("should call onValidate with an null when the user changes the value after there was an error", async () => {
// Arrange
const handleValidate = jest.fn();
const errorMsg = "error message";
Expand All @@ -1570,7 +1570,7 @@ describe("TextArea", () => {
// Assert
expect(handleValidate.mock.calls).toStrictEqual([
[errorMsg],
[""],
[null],
]);
});

Expand Down
4 changes: 2 additions & 2 deletions packages/wonder-blocks-form/src/components/text-area.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ const TextArea = React.forwardRef<HTMLTextAreaElement, TextAreaProps>(
// If instantValidation is false and there is an error
// message, error needs to be cleared when the user updates
// the value
setErrorMessage("");
setErrorMessage(null);
if (onValidate) {
onValidate("");
onValidate(null);
}
}
}
Expand Down

0 comments on commit d2aeaf8

Please sign in to comment.