Explorar el Código

Merge pull request #6791 from weseek/fix/106917-107060-toc-rendering

fix: Update useCallback for redo calcViewHeight
ryoji-s hace 3 años
padre
commit
f92bcabe1f
Se han modificado 1 ficheros con 5 adiciones y 5 borrados
  1. 5 5
      packages/app/src/components/TableOfContents.tsx

+ 5 - 5
packages/app/src/components/TableOfContents.tsx

@@ -6,13 +6,10 @@ import { useIsUserPage } from '~/stores/context';
 import { useTocOptions } from '~/stores/renderer';
 import loggerFactory from '~/utils/logger';
 
-
 import { StickyStretchableScroller } from './StickyStretchableScroller';
 
-
 import styles from './TableOfContents.module.scss';
 
-
 // eslint-disable-next-line no-unused-vars
 const logger = loggerFactory('growi:TableOfContents');
 
@@ -28,7 +25,10 @@ const TableOfContents = (): JSX.Element => {
     // calculate absolute top of '#revision-toc' element
     const parentElem = document.querySelector('.grw-side-contents-container');
     const containerElem = document.querySelector('#revision-toc');
-    if (parentElem == null || containerElem == null) {
+
+    // rendererOptions for redo calcViewHeight()
+    // see: https://github.com/weseek/growi/pull/6791
+    if (parentElem == null || containerElem == null || rendererOptions == null) {
       return 0;
     }
     const parentBottom = parentElem.getBoundingClientRect().bottom;
@@ -45,7 +45,7 @@ const TableOfContents = (): JSX.Element => {
     }
     // bottom - revisionToc top
     return bottom - (containerTop + containerPaddingTop);
-  }, [isUserPage]);
+  }, [isUserPage, rendererOptions]);
 
   return (
     <div id="revision-toc" className={`revision-toc ${styles['revision-toc']}`}>