Skip to content

Commit

Permalink
fix: a11y aria-valuetext issue with NumberInput
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraghazra committed Sep 9, 2020
1 parent 7452121 commit 4a3af5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/number-input/NumberInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/number-input/__test__/NumberInput.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ describe("NumberInput", () => {
});

test("NumberInput renders with no a11y violations", async () => {
const { container } = render(<NumberInputComp defaultValue={0} />);
const { container } = render(<NumberInputComp />);
const results = await axe(container);

expect(results).toHaveNoViolations();
Expand Down

0 comments on commit 4a3af5f

Please sign in to comment.