File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import {IconSearch} from 'components/Icon/IconSearch';
77import  Head  from  'next/head' ; 
88import  Link  from  'next/link' ; 
99import  Router  from  'next/router' ; 
10- import  { useState ,  useCallback ,  useEffect }  from  'react' ; 
10+ import  { useState ,  useCallback ,  useEffect ,   useLayoutEffect }  from  'react' ; 
1111import  *  as  React  from  'react' ; 
1212import  { createPortal }  from  'react-dom' ; 
1313import  { siteConfig }  from  'siteConfig' ; 
@@ -108,6 +108,15 @@ export function Search({
108108} : SearchProps )  { 
109109  const  [ isShowing ,  setIsShowing ]  =  useState ( false ) ; 
110110
111+     useLayoutEffect ( ( )  =>  { 
112+     const  scrollBarWidth  =  window . innerWidth  -  document . body . clientWidth ; 
113+     if  ( isShowing )  { 
114+       document . body . style . marginRight  =  `${ scrollBarWidth }  ; 
115+     }  else  if  ( ! isShowing )  { 
116+       document . body . style . marginRight  =  '0px' ; 
117+     } 
118+   } ,  [ isShowing ] ) ; 
119+ 
111120  const  importDocSearchModalIfNeeded  =  useCallback ( 
112121    function  importDocSearchModalIfNeeded ( )  { 
113122      if  ( DocSearchModal )  { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments