Skip to content

Commit 7595221

Browse files
author
Eric Olkowski
committed
Updated logic for applying arialabelledby attribute
1 parent fcc0603 commit 7595221

File tree

1 file changed

+2
-1
lines changed
  • packages/react-core/src/components/Switch

1 file changed

+2
-1
lines changed

packages/react-core/src/components/Switch/Switch.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class Switch extends React.Component<SwitchProps & OUIAProps, { ouiaStateId: str
8787
...props
8888
} = this.props;
8989

90-
const isAriaLabelledBy = !ariaLabel || ariaLabelledBy;
90+
const hasAccessibleName = label || ariaLabel || ariaLabelledBy;
91+
const isAriaLabelledBy = hasAccessibleName && (!ariaLabel || ariaLabelledBy);
9192
const useDefaultAriaLabelledBy = !ariaLabelledBy && !ariaLabel;
9293
const ariaLabelledByIds = ariaLabelledBy ?? `${this.id}-label`;
9394

0 commit comments

Comments
 (0)