File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed 
packages/react-devtools-shared/src/devtools/views Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -64,8 +64,9 @@ export default function SearchInput({
6464    const  handleKeyDown  =  ( event : KeyboardEvent )  =>  { 
6565      const  { key,  metaKey}  =  event ; 
6666      if  ( key  ===  'f'  &&  metaKey )  { 
67-         if  ( inputRef . current  !==  null )  { 
68-           inputRef . current . focus ( ) ; 
67+         const  inputElement  =  inputRef . current ; 
68+         if  ( inputElement  !==  null )  { 
69+           inputElement . focus ( ) ; 
6970          event . preventDefault ( ) ; 
7071          event . stopPropagation ( ) ; 
7172        } 
@@ -75,10 +76,14 @@ export default function SearchInput({
7576    // It's important to listen to the ownerDocument to support the browser extension. 
7677    // Here we use portals to render individual tabs (e.g. Profiler), 
7778    // and the root document might belong to a different window. 
78-     const  ownerDocument  =  inputRef . current . ownerDocument ; 
79-     ownerDocument . addEventListener ( 'keydown' ,  handleKeyDown ) ; 
79+     const  ownerDocumentElement  =  inputRef . current . ownerDocument . documentElement ; 
80+     if  ( ownerDocumentElement  ===  null )  { 
81+       return ; 
82+     } 
83+     ownerDocumentElement . addEventListener ( 'keydown' ,  handleKeyDown ) ; 
8084
81-     return  ( )  =>  ownerDocument . removeEventListener ( 'keydown' ,  handleKeyDown ) ; 
85+     return  ( )  => 
86+       ownerDocumentElement . removeEventListener ( 'keydown' ,  handleKeyDown ) ; 
8287  } ,  [ ] ) ; 
8388
8489  return  ( 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments