Skip to content

Commit

Permalink
fix(many): hide required asterisks from screenreaders
Browse files Browse the repository at this point in the history
  • Loading branch information
balzss committed Dec 3, 2024
1 parent dd1e12c commit 78aec71
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/ui-checkbox/src/Checkbox/CheckboxFacade/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const generateComponentTheme = (theme: Theme): CheckboxFacadeTheme => {
color: colors?.contrasts?.white1010,
borderWidth: borders?.widthSmall,
borderColor: colors?.contrasts?.grey3045,
errorBorderColor: colors?.ui?.textError,
errorBorderColor: colors?.contrasts?.red5782,
borderRadius: borders?.radiusMedium,
background: colors?.contrasts?.white1010,
marginRight: spacing?.xSmall,
Expand Down
2 changes: 1 addition & 1 deletion packages/ui-checkbox/src/Checkbox/ToggleFacade/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const generateComponentTheme = (theme: Theme): ToggleFacadeTheme => {

const componentVariables: ToggleFacadeTheme = {
color: colors?.contrasts?.white1010,
errorBorderColor: colors?.ui?.textError,
errorBorderColor: colors?.contrasts?.red5782,
background: colors?.contrasts?.grey1111,
borderColor: colors?.contrasts?.grey3045,
borderWidth: borders?.widthSmall,
Expand Down
16 changes: 14 additions & 2 deletions packages/ui-checkbox/src/Checkbox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,13 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
>
{label}
{isRequired && label && (
<span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
<span
css={this.invalid ? styles?.requiredInvalid : {}}
aria-hidden={true}
>
{' '}
*
</span>
)}
</ToggleFacade>
)
Expand All @@ -248,7 +254,13 @@ class Checkbox extends Component<CheckboxProps, CheckboxState> {
>
{label}
{isRequired && label && (
<span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
<span
css={this.invalid ? styles?.requiredInvalid : {}}
aria-hidden={true}
>
{' '}
*
</span>
)}
</CheckboxFacade>
)
Expand Down
8 changes: 7 additions & 1 deletion packages/ui-number-input/src/NumberInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,13 @@ class NumberInput extends Component<NumberInputProps, NumberInputState> {
<React.Fragment>
{rawLabel}
{isRequired && (
<span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
<span
css={this.invalid ? styles?.requiredInvalid : {}}
aria-hidden={true}
>
{' '}
*
</span>
)}
</React.Fragment>
) : (
Expand Down
8 changes: 7 additions & 1 deletion packages/ui-radio-input/src/RadioInputGroup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ class RadioInputGroup extends Component<
<React.Fragment>
{description}
{isRequired && description && (
<span css={this.invalid ? styles?.invalidAsterisk : {}}> *</span>
<span
css={this.invalid ? styles?.invalidAsterisk : {}}
aria-hidden={true}
>
{' '}
*
</span>
)}
</React.Fragment>
) : (
Expand Down
8 changes: 7 additions & 1 deletion packages/ui-text-area/src/TextArea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,13 @@ class TextArea extends Component<TextAreaProps> {
<React.Fragment>
{this.props.label}
{required && (
<span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
<span
css={this.invalid ? styles?.requiredInvalid : {}}
aria-hidden={true}
>
{' '}
*
</span>
)}
</React.Fragment>
) : (
Expand Down
8 changes: 7 additions & 1 deletion packages/ui-text-input/src/TextInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,13 @@ class TextInput extends Component<TextInputProps, TextInputState> {
<React.Fragment>
{rawLabel}
{isRequired && (
<span css={this.invalid ? styles?.requiredInvalid : {}}> *</span>
<span
css={this.invalid ? styles?.requiredInvalid : {}}
aria-hidden={true}
>
{' '}
*
</span>
)}
</React.Fragment>
) : (
Expand Down

0 comments on commit 78aec71

Please sign in to comment.