File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
packages/ui-breadcrumb/src/Breadcrumb/BreadcrumbLink Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff 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 tag in a span and puts the aria-describedby on that instead of the anchor tag
92+ // to avoid SRs reading the text twice when there is already an aria-label
93+ { ...( href && { as : 'span' } ) }
94+ >
8795 < Link
8896 { ...props }
8997 href = { href }
@@ -95,6 +103,13 @@ class BreadcrumbLink extends Component<
95103 elementRef = { this . handleRef }
96104 forceButtonRole = { false }
97105 { ...( isCurrentPage && { 'aria-current' : 'page' } ) }
106+ { ...( isTruncated &&
107+ // put an aria-label on it when it's just a text (e.g. neither a button or a link)
108+ // or when it's a link (to have discernible text see: https://dequeuniversity.com/rules/axe/4.10/link-name)
109+ ( ! isInteractive || href ) && {
110+ ...( typeof children === 'string' && { 'aria-label' : children } ) ,
111+ ...( ! isInteractive && { role : 'text' } )
112+ } ) }
98113 >
99114 < TruncateText
100115 onUpdate = { ( isTruncated ) => this . handleTruncation ( isTruncated ) }
You can’t perform that action at this time.
0 commit comments