소스 검색

fix: enhance auto-scroll detection during rendering process

Yuki Takei 2 달 전
부모
커밋
de79d06173
1개의 변경된 파일6개의 추가작업 그리고 0개의 파일을 삭제
  1. 6 0
      packages/remark-drawio/src/components/DrawioViewer.tsx

+ 6 - 0
packages/remark-drawio/src/components/DrawioViewer.tsx

@@ -128,6 +128,7 @@ export const DrawioViewer = memo((props: DrawioViewerProps): JSX.Element => {
   useEffect(() => {
     if (error != null) {
       onRenderingUpdated?.(null);
+      // finish rendering to allow auto-scroll system to detect the upcoming layout shift
       drawioContainerRef.current?.setAttribute(
         GROWI_IS_CONTENT_RENDERING_ATTR,
         'false',
@@ -174,6 +175,11 @@ export const DrawioViewer = memo((props: DrawioViewerProps): JSX.Element => {
       for (const _entry of entries) {
         // setElementWidth(entry.contentRect.width);
         onRenderingStart?.();
+        // Signal re-rendering in progress so the auto-scroll system can detect the upcoming layout shift
+        drawioContainerRef.current?.setAttribute(
+          GROWI_IS_CONTENT_RENDERING_ATTR,
+          'true',
+        );
         renderDrawioWithDebounce();
       }
     });