diff --git a/frontend/app/tab/tab.tsx b/frontend/app/tab/tab.tsx index 0333bba2c..4da6fe350 100644 --- a/frontend/app/tab/tab.tsx +++ b/frontend/app/tab/tab.tsx @@ -19,9 +19,9 @@ const TabContent = ({ tabId }: { tabId: string }) => { const layoutStateAtom = useMemo(() => getLayoutStateAtomForTab(tabId, tabAtom), [tabAtom, tabId]); const tabData = useAtomValue(tabAtom); - const renderBlock = useCallback((tabData: TabLayoutData, onClose: () => void) => { + const renderBlock = useCallback((tabData: TabLayoutData, ready: boolean, onClose: () => void) => { // console.log("renderBlock", tabData); - if (!tabData.blockId) { + if (!tabData.blockId || !ready) { return null; } return ; diff --git a/frontend/faraday/lib/TileLayout.tsx b/frontend/faraday/lib/TileLayout.tsx index 7a0b4b75d..8e336c569 100644 --- a/frontend/faraday/lib/TileLayout.tsx +++ b/frontend/faraday/lib/TileLayout.tsx @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 import clsx from "clsx"; -import { CSSProperties, RefObject, useCallback, useEffect, useLayoutEffect, useRef, useState } from "react"; +import { CSSProperties, RefObject, useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react"; import { useDrag, useDragLayer, useDrop } from "react-dnd"; import { useLayoutTreeStateReducerAtom } from "./layoutAtom.js"; @@ -183,6 +183,7 @@ export const TileLayout = ({ layoutTreeStateAtom, className, renderContent, renderContent={renderContent} transform={layoutLeafTransforms[leaf.id]} onLeafClose={onLeafClose} + ready={animate} /> ); })} @@ -209,12 +210,13 @@ interface TileNodeProps { layoutNode: LayoutNode; renderContent: ContentRenderer; onLeafClose: (node: LayoutNode) => void; + ready: boolean; transform: CSSProperties; } const dragItemType = "TILE_ITEM"; -const TileNode = ({ layoutNode, renderContent, transform, onLeafClose }: TileNodeProps) => { +const TileNode = ({ layoutNode, renderContent, transform, onLeafClose, ready }: TileNodeProps) => { const tileNodeRef = useRef(null); const [{ isDragging, dragItem }, drag, dragPreview] = useDrag( @@ -245,6 +247,16 @@ const TileNode = ({ layoutNode, renderContent, transform, onLeafClose }: Til onLeafClose(layoutNode); }, [layoutNode, onLeafClose]); + const leafContent = useMemo(() => { + return ( + layoutNode.data && ( +
+ {renderContent(layoutNode.data, ready, onClose)} +
+ ) + ); + }, [, layoutNode.data, ready, onClose]); + return (
({ layoutNode, renderContent, transform, onLeafClose }: Til ...transform, }} > - {layoutNode.data && ( -
- {renderContent(layoutNode.data, onClose)} -
- )} + {leafContent}
); }; diff --git a/frontend/faraday/lib/model.ts b/frontend/faraday/lib/model.ts index 2824ed091..dda6a7042 100644 --- a/frontend/faraday/lib/model.ts +++ b/frontend/faraday/lib/model.ts @@ -130,4 +130,4 @@ export type WritableLayoutNodeAtom = WritableAtom, [value: Layo */ export type WritableLayoutTreeStateAtom = WritableAtom, [value: LayoutTreeState], void>; -export type ContentRenderer = (data: T, onClose?: () => void) => React.ReactNode; +export type ContentRenderer = (data: T, ready: boolean, onClose?: () => void) => React.ReactNode;