diff --git a/src/number-input/NumberInput.ts b/src/number-input/NumberInput.ts index 7ad69a2cf..8bc17d7a9 100644 --- a/src/number-input/NumberInput.ts +++ b/src/number-input/NumberInput.ts @@ -106,7 +106,10 @@ export const useNumberInput = createHook< * @see https://www.w3.org/TR/wai-aria-practices-1.1/#wai-aria-roles-states-and-properties-18 * @see https://www.w3.org/TR/wai-aria-1.1/#aria-valuetext */ - const ariaValueText = getAriaValueText?.(value) ?? String(value); + const ariaValueText = + value === null || value === "" + ? undefined + : getAriaValueText?.(value) ?? String(value); /** * The `onChange` handler filters out any character typed diff --git a/src/number-input/__test__/NumberInput.test.tsx b/src/number-input/__test__/NumberInput.test.tsx index 20c6ab6b1..69e332e3e 100644 --- a/src/number-input/__test__/NumberInput.test.tsx +++ b/src/number-input/__test__/NumberInput.test.tsx @@ -162,7 +162,7 @@ describe("NumberInput", () => { }); test("NumberInput renders with no a11y violations", async () => { - const { container } = render(); + const { container } = render(); const results = await axe(container); expect(results).toHaveNoViolations();