Skip to content

Commit 638ffbe

Browse files
committed
fix(ui-breadcrumb): fix Breadcrumb accessibility issues
INSTUI-4676
1 parent 390b294 commit 638ffbe

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink/index.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class BreadcrumbLink extends Component<
6868
this.setState({ isTruncated })
6969
}
7070
}
71+
7172
render() {
7273
const {
7374
children,
@@ -82,8 +83,15 @@ class BreadcrumbLink extends Component<
8283
const { isTruncated } = this.state
8384
const props = omitProps(this.props, BreadcrumbLink.allowedProps)
8485

86+
const isInteractive = onClick || href
8587
return (
86-
<Tooltip renderTip={children} preventTooltip={!isTruncated}>
88+
<Tooltip
89+
renderTip={children}
90+
preventTooltip={!isTruncated}
91+
// this wraps the achor/button tag in a span and puts the aria-describedby on that instead of the anchor/button tag
92+
// to avoid SRs reading the text twice when there is already an aria-label
93+
{...(isInteractive && { as: 'span' })}
94+
>
8795
<Link
8896
{...props}
8997
href={href}
@@ -95,6 +103,10 @@ class BreadcrumbLink extends Component<
95103
elementRef={this.handleRef}
96104
forceButtonRole={false}
97105
{...(isCurrentPage && { 'aria-current': 'page' })}
106+
{...(isTruncated && {
107+
...(typeof children === 'string' && { 'aria-label': children }),
108+
...(!isInteractive && { role: 'text' })
109+
})}
98110
>
99111
<TruncateText
100112
onUpdate={(isTruncated) => this.handleTruncation(isTruncated)}

0 commit comments

Comments
 (0)