Skip to content

Commit

Permalink
fix: address a11y issues in input related components
Browse files Browse the repository at this point in the history
Signed-off-by: Mason Hu <[email protected]>
  • Loading branch information
mas-who committed Feb 21, 2024
1 parent 829ba13 commit 6e79c95
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/components/Input/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ const Input = ({
const helpId = useId();
const hasError = !!error;

const description = [help ? helpId : null, success ? validationId : null]
.filter(Boolean)
.join(" ");
const commonProps = {
"aria-describedby": [help ? helpId : null, success ? validationId : null]
.filter(Boolean)
.join(" "),
"aria-describedby": !description ? undefined : description,
"aria-errormessage": hasError ? validationId : null,
"aria-invalid": hasError,
id: inputId,
Expand Down
1 change: 0 additions & 1 deletion src/components/Input/__snapshots__/Input.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ exports[`Input renders 1`] = `
class="p-form__control u-clearfix"
>
<input
aria-describedby=""
aria-invalid="false"
class="p-form-validation__input"
id="test-id"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ exports[`<TablePaginationControls /> renders table pagination controls and match

exports[`<TablePaginationControls /> renders table pagination controls and matches the snapshot 2`] = `
<input
aria-describedby=""
aria-invalid="false"
class="p-form-validation__input u-no-margin--bottom pagination-input"
id="paginationPageInput"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ exports[`<TablePagination /> renders table pagination and matches the snapshot 1
class="p-form__control u-clearfix"
>
<input
aria-describedby=""
aria-invalid="false"
class="p-form-validation__input u-no-margin--bottom pagination-input"
id="paginationPageInput"
Expand Down

0 comments on commit 6e79c95

Please sign in to comment.