Skip to content

Commit ccf1e95

Browse files
committed
Accessibility#9196
1 parent 6ff91a4 commit ccf1e95

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/components/search.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ import {LightTheme} from '../theme'
1010
import {LinkNoUnderline} from './link'
1111
import * as getNav from '../util/get-nav'
1212
import omit from '../util/omit'
13+
import {announce} from '../util/aria-live'
1314

14-
const SearchResults = ({results, getItemProps, highlightedIndex}) => {
15+
const SearchResults = ({results, getItemProps, highlightedIndex, isOpen}) => {
1516
const siteMetadata = useSiteMetadata()
1617

18+
React.useEffect(() => {
19+
if (isOpen && (!results || results.length === 0)) {
20+
announce('No results')
21+
}
22+
}, [results, isOpen])
23+
1724
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>
1926
}
2027

2128
return (

0 commit comments

Comments
 (0)