Просмотр исходного кода

Merge pull request #5982 from overleaf/jel-pdf-detach-childless

Editor tab in detach layout when no PDF tab

GitOrigin-RevId: 979c179dbe4b447e1eb222b2649d6a235f6ab229
Jessica Lawshe 4 лет назад
Родитель
Сommit
956724c838
1 измененных файлов с 2 добавлено и 16 удалено
  1. 2 16
      services/web/frontend/js/shared/context/layout-context.js

+ 2 - 16
services/web/frontend/js/shared/context/layout-context.js

@@ -4,10 +4,8 @@ import {
   useCallback,
   useMemo,
   useEffect,
-  useRef,
 } from 'react'
 import PropTypes from 'prop-types'
-import { debounce } from 'lodash'
 import useScopeValue from '../hooks/use-scope-value'
 import useDetachLayout from '../hooks/use-detach-layout'
 import { useIdeContext } from './ide-context'
@@ -97,16 +95,6 @@ export function LayoutProvider({ children }) {
     [setPdfLayout, setView]
   )
 
-  // helper to avoid changing layout multiple times in rapid succession. This is
-  // especially useful for calling `changeLayout` as a side-effect. Calling
-  // `changeLayout` multiple times on page load cause layout rendering issues do
-  // to timming clash with Angular.
-  const debouncedChangeLayout = useRef(
-    debounce((newLayout, newView) => changeLayout(newLayout, newView), 1000, {
-      leading: true,
-    })
-  ).current
-
   const {
     reattach,
     detach,
@@ -129,11 +117,9 @@ export function LayoutProvider({ children }) {
     if (detachIsLinking || detachIsLinked) {
       // the tab is linked to a detached tab (or about to be linked); show
       // editor only
-      debouncedChangeLayout('flat', 'editor')
-    } else {
-      debouncedChangeLayout('sideBySide')
+      changeLayout('flat', 'editor')
     }
-  }, [detachRole, detachIsLinking, detachIsLinked, debouncedChangeLayout])
+  }, [detachRole, detachIsLinking, detachIsLinked, changeLayout])
 
   const value = useMemo(
     () => ({