Răsfoiți Sursa

enhance: allow rendering empty portals once

Konstantinos Kaloutas 2 ani în urmă
părinte
comite
2043f3a5a4

+ 8 - 9
tldraw/apps/tldraw-logseq/src/lib/shapes/LogseqPortalShape.tsx

@@ -298,14 +298,13 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
       }
     }, [innerHeight, this.props.isAutoResizing])
 
+    const [loaded, setLoaded] = React.useState(false)
+
     React.useEffect(() => {
-      if (!this.initialHeightCalculated) {
-        setTimeout(() => {
-          this.onResetBounds()
-          app.persist(true)
-        })
-      }
-    }, [this.initialHeightCalculated])
+      setTimeout(function () {
+        setLoaded(true)
+      })
+    }, [])
 
     return (
       <>
@@ -325,11 +324,11 @@ export class LogseqPortalShape extends TLBoxShape<LogseqPortalShapeProps> {
           className="relative tl-logseq-cp-container"
           style={{ overflow: this.props.isAutoResizing ? 'visible' : 'auto' }}
         >
-          {this.props.blockType === 'B' && this.props.compact ? (
+          {loaded && (this.props.blockType === 'B' && this.props.compact ? (
             <Block blockId={pageId} />
           ) : (
             <Page pageName={pageId} />
-          )}
+          ))}
         </div>
       </>
     )