File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -20,13 +20,21 @@ function useModalBehaviour(onClose: () => void) {
20
20
useEffect ( ( ) => {
21
21
const prev = document . documentElement . style . overflow ;
22
22
document . documentElement . style . overflow = 'hidden' ;
23
- return ( ) => ( document . documentElement . style . overflow = prev ) ;
23
+ return ( ) => {
24
+ document . documentElement . style . overflow = prev ;
25
+ } ;
24
26
} , [ ] ) ;
25
27
26
28
useEffect ( ( ) => {
27
- const h = ( e : KeyboardEvent ) => e . key === 'Escape' && onClose ( ) ;
29
+ const h = ( e : KeyboardEvent ) => {
30
+ if ( e . key === 'Escape' ) {
31
+ onClose ( ) ;
32
+ }
33
+ } ;
28
34
window . addEventListener ( 'keydown' , h ) ;
29
- return ( ) => window . removeEventListener ( 'keydown' , h ) ;
35
+ return ( ) => {
36
+ window . removeEventListener ( 'keydown' , h ) ;
37
+ } ;
30
38
} , [ onClose ] ) ;
31
39
}
32
40
You can’t perform that action at this time.
0 commit comments