File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -10,12 +10,19 @@ import {LightTheme} from '../theme'
10
10
import { LinkNoUnderline } from './link'
11
11
import * as getNav from '../util/get-nav'
12
12
import omit from '../util/omit'
13
+ import { announce } from '../util/aria-live'
13
14
14
- const SearchResults = ( { results, getItemProps, highlightedIndex} ) => {
15
+ const SearchResults = ( { results, getItemProps, highlightedIndex, isOpen } ) => {
15
16
const siteMetadata = useSiteMetadata ( )
16
17
18
+ React . useEffect ( ( ) => {
19
+ if ( isOpen && ( ! results || results . length === 0 ) ) {
20
+ announce ( 'No results' )
21
+ }
22
+ } , [ results , isOpen ] )
23
+
17
24
if ( ! results || results . length === 0 ) {
18
- return < Box sx = { { fontSize : 2 , px : 3 , py : 3 } } > No results</ Box >
25
+ return < Box sx = { { fontSize : 2 , px : 3 , py : 3 } } aria-live = "assertive" > No results</ Box >
19
26
}
20
27
21
28
return (
You can’t perform that action at this time.
0 commit comments