From d2aeaf80f44355651f0e5662ad93ba4944fa45c0 Mon Sep 17 00:00:00 2001 From: Bea Esguerra Date: Wed, 6 Nov 2024 13:32:07 -0700 Subject: [PATCH] set error message to null instead of empty string when clearing the error --- .../src/components/__tests__/text-area.test.tsx | 4 ++-- packages/wonder-blocks-form/src/components/text-area.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/wonder-blocks-form/src/components/__tests__/text-area.test.tsx b/packages/wonder-blocks-form/src/components/__tests__/text-area.test.tsx index b93c6b823..7fcd2b973 100644 --- a/packages/wonder-blocks-form/src/components/__tests__/text-area.test.tsx +++ b/packages/wonder-blocks-form/src/components/__tests__/text-area.test.tsx @@ -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"; @@ -1570,7 +1570,7 @@ describe("TextArea", () => { // Assert expect(handleValidate.mock.calls).toStrictEqual([ [errorMsg], - [""], + [null], ]); }); diff --git a/packages/wonder-blocks-form/src/components/text-area.tsx b/packages/wonder-blocks-form/src/components/text-area.tsx index 67171e61f..fcab8d600 100644 --- a/packages/wonder-blocks-form/src/components/text-area.tsx +++ b/packages/wonder-blocks-form/src/components/text-area.tsx @@ -255,9 +255,9 @@ const TextArea = React.forwardRef( // 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); } } }