From 2e8b1ac086d69765ca1cabcdaa16d31f4fa05446 Mon Sep 17 00:00:00 2001 From: Adam Kudrna Date: Mon, 25 Sep 2023 16:25:59 +0200 Subject: [PATCH] Remove invisible `InputGroup` and `Radio` labels from code since parent `
`s still have accessible `` --- src/components/InputGroup/InputGroup.jsx | 19 +++++++++---------- src/components/InputGroup/InputGroup.scss | 5 ----- src/components/Radio/Radio.jsx | 19 +++++++++---------- src/components/Radio/Radio.scss | 5 ----- tests/propTests/isLabelVisibleTest.js | 2 +- 5 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/components/InputGroup/InputGroup.jsx b/src/components/InputGroup/InputGroup.jsx index ef5e7b9f..2b9cc9d5 100644 --- a/src/components/InputGroup/InputGroup.jsx +++ b/src/components/InputGroup/InputGroup.jsx @@ -69,16 +69,15 @@ export const InputGroup = ({ > {label} -
- {label} -
+ {isLabelVisible && ( +
+ {label} +
+ )}
{label} -
- {label} -
+ {isLabelVisible && ( +
+ {label} +
+ )}
{ diff --git a/src/components/Radio/Radio.scss b/src/components/Radio/Radio.scss index b36b3a09..d102dfec 100644 --- a/src/components/Radio/Radio.scss +++ b/src/components/Radio/Radio.scss @@ -64,11 +64,6 @@ @include variants.validation(warning); } -// Invisible label -.isLabelHidden { - @include accessibility.hide-text(); -} - // Layouts .isRootLayoutVertical, .isRootLayoutHorizontal { diff --git a/tests/propTests/isLabelVisibleTest.js b/tests/propTests/isLabelVisibleTest.js index 91afe220..ade8a8a1 100644 --- a/tests/propTests/isLabelVisibleTest.js +++ b/tests/propTests/isLabelVisibleTest.js @@ -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'); }