File tree Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import React, {
66 useRef ,
77 useState
88} from 'react' ;
9+ import useKeyDownHandlers from '../../modules/IDE/hooks/useKeyDownHandlers' ;
910import { MenuOpenContext , NavBarContext } from './contexts' ;
1011
1112function NavBar ( { children } ) {
@@ -31,18 +32,9 @@ function NavBar({ children }) {
3132 } ;
3233 } , [ nodeRef , setDropdownOpen ] ) ;
3334
34- // TODO: replace with `useKeyDownHandlers` after #2052 is merged
35- useEffect ( ( ) => {
36- function handleKeyDown ( e ) {
37- if ( e . keyCode === 27 ) {
38- setDropdownOpen ( 'none' ) ;
39- }
40- }
41- document . addEventListener ( 'keydown' , handleKeyDown , false ) ;
42- return ( ) => {
43- document . removeEventListener ( 'keydown' , handleKeyDown , false ) ;
44- } ;
45- } , [ setDropdownOpen ] ) ;
35+ useKeyDownHandlers ( {
36+ 'escape' : ( ) => setDropdownOpen ( 'none' )
37+ } ) ;
4638
4739 const clearHideTimeout = useCallback ( ( ) => {
4840 if ( timerRef . current ) {
You can’t perform that action at this time.
0 commit comments