Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove invisible InputGroup and Radio labels from code since parent <fieldset>s still have accessible <legend> #495

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions src/components/InputGroup/InputGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,15 @@ export const InputGroup = ({
>
{label}
</legend>
<div
aria-hidden
className={classNames(
styles.label,
!isLabelVisible && styles.isLabelHidden,
)}
id={id && `${id}__displayLabel`}
>
{label}
</div>
{isLabelVisible && (
<div
aria-hidden
className={styles.label}
id={id && `${id}__displayLabel`}
>
{label}
</div>
)}
<div className={styles.field}>
<div
className={styles.inputGroup}
Expand Down
5 changes: 0 additions & 5 deletions src/components/InputGroup/InputGroup.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@
@include variants.validation(warning);
}

// Invisible label
.isLabelHidden {
@include accessibility.hide-text();
}

// Layouts
.isRootLayoutVertical,
.isRootLayoutHorizontal {
Expand Down
19 changes: 9 additions & 10 deletions src/components/Radio/Radio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,15 @@ export const Radio = ({
>
{label}
</legend>
<div
aria-hidden
className={classNames(
styles.label,
!isLabelVisible && styles.isLabelHidden,
)}
id={id && `${id}__displayLabel`}
>
{label}
</div>
{isLabelVisible && (
<div
aria-hidden
className={styles.label}
id={id && `${id}__displayLabel`}
>
{label}
</div>
)}
<div className={styles.field}>
<div className={styles.options}>
{
Expand Down
5 changes: 0 additions & 5 deletions src/components/Radio/Radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@
@include variants.validation(warning);
}

// Invisible label
.isLabelHidden {
@include accessibility.hide-text();
}

// Layouts
.isRootLayoutVertical,
.isRootLayoutHorizontal {
Expand Down
2 changes: 1 addition & 1 deletion tests/propTests/isLabelVisibleTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const isLabelVisibleTest = (HtmlTag = 'label') => (
},
(rootElement) => {
if (HtmlTag === 'legend') {
expect(within(rootElement).getByTestId('id__displayLabel')).toHaveClass('isLabelHidden');
expect(within(rootElement).queryByTestId('id__displayLabel')).not.toBeInTheDocument();
} else {
expect(within(rootElement).getByText('label')).toHaveClass('isLabelHidden');
}
Expand Down