1
- import React from 'react ' ;
1
+ import { useIntl } from '@edx/frontend-platform/i18n ' ;
2
2
import {
3
3
Folder , TextFields , VideoCamera , Article ,
4
4
} from '@openedx/paragon/icons' ;
5
5
import { getConfig } from '@edx/frontend-platform' ;
6
6
import { Icon } from '@openedx/paragon' ;
7
7
import PropTypes from 'prop-types' ;
8
8
import CoursewareSearchEmpty from './CoursewareSearchEmpty' ;
9
+ import messages from './messages' ;
9
10
10
11
const iconTypeMapping = {
11
12
text : TextFields ,
@@ -21,6 +22,8 @@ const CoursewareSearchResults = ({ results = [] }) => {
21
22
return < CoursewareSearchEmpty /> ;
22
23
}
23
24
25
+ const { formatMessage } = useIntl ( ) ;
26
+
24
27
const baseUrl = `${ getConfig ( ) . LMS_BASE_URL } ` ;
25
28
26
29
return (
@@ -42,24 +45,30 @@ const CoursewareSearchResults = ({ results = [] }) => {
42
45
rel : 'nofollow' ,
43
46
} : { href : `${ baseUrl } ${ url } ` } ;
44
47
48
+ const ariaSeaparator = formatMessage ( messages . searchResultsBreadcrumbSeparator ) ;
49
+ const ariaLocation = location ?. length ? formatMessage ( messages . searchResultsBreadcrumb , { path : location . join ( ariaSeaparator ) } ) : '' ;
50
+
45
51
return (
46
52
< a key = { id } className = "courseware-search-results__item" { ...linkProps } >
47
53
< div className = "courseware-search-results__icon" > < Icon src = { icon } /> </ div >
48
54
< div className = "courseware-search-results__info" >
49
55
< div className = "courseware-search-results__title" >
50
- < span > { title } </ span >
51
- { contentHits ? ( < em > { contentHits } </ em > ) : null }
56
+ < h3 > { title } </ h3 >
57
+ { contentHits ? ( < em aria-hidden = "true" > { contentHits } </ em > ) : null }
52
58
</ div >
53
- { location ?. length ? (
54
- < ul className = "courseware-search-results__breadcrumbs" >
55
- {
59
+
60
+ < div aria-label = { ariaLocation } >
61
+ { location ?. length ? (
62
+ < ul className = "courseware-search-results__breadcrumbs" aria-hidden = "true" >
63
+ {
56
64
// This ignore is necessary because the breadcrumb texts might have duplicates.
57
65
// The breadcrumbs are not expected to change.
58
66
// eslint-disable-next-line react/no-array-index-key
59
67
location . map ( ( breadcrumb , i ) => ( < li key = { `${ i } :${ breadcrumb } ` } > < div > { breadcrumb } </ div > </ li > ) )
60
68
}
61
- </ ul >
62
- ) : null }
69
+ </ ul >
70
+ ) : null }
71
+ </ div >
63
72
</ div >
64
73
</ a >
65
74
) ;
0 commit comments