File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 1
- import React from 'react' ;
1
+ import React , { useEffect } from 'react' ;
2
2
import useAnnounceStore from './announceStore' ;
3
3
4
4
const offScreenStyle = {
@@ -16,6 +16,15 @@ const offScreenStyle = {
16
16
export const A11yAnnouncer : React . FC = ( ) => {
17
17
const message = useAnnounceStore ( state => state . message ) ;
18
18
19
+ useEffect ( ( ) => {
20
+ window . addEventListener ( 'cick' , ( ) => {
21
+ if ( window . document . activeElement ?. getAttribute ( 'r3f-a11y' ) ) {
22
+ //@ts -ignore
23
+ window . document . activeElement . blur ( ) ;
24
+ }
25
+ } ) ;
26
+ } ) ;
27
+
19
28
return (
20
29
< div style = { offScreenStyle } aria-atomic = "true" aria-live = "assertive" >
21
30
{ message }
Original file line number Diff line number Diff line change 1
1
import create from 'zustand' ;
2
- import { useEffect } from 'react' ;
3
2
4
3
type State = {
5
4
message : string ;
6
5
a11yScreenReader : ( message : string ) => void ;
7
6
} ;
8
7
9
8
const useAnnounceStore = create < State > ( set => {
10
- useEffect ( ( ) => {
11
- window . addEventListener ( 'cick' , ( ) => {
12
- if ( window . document . activeElement ?. getAttribute ( 'r3f-a11y' ) ) {
13
- //@ts -ignore
14
- window . document . activeElement . blur ( ) ;
15
- }
16
- } ) ;
17
- } ) ;
18
-
19
9
return {
20
10
message : '' ,
21
11
a11yScreenReader : message => {
You can’t perform that action at this time.
0 commit comments