diff --git a/apps/client/src/features/editor/components/base-embed/base-embed-view.tsx b/apps/client/src/features/editor/components/base-embed/base-embed-view.tsx index f371dfb2c..e60a4b0f9 100644 --- a/apps/client/src/features/editor/components/base-embed/base-embed-view.tsx +++ b/apps/client/src/features/editor/components/base-embed/base-embed-view.tsx @@ -24,6 +24,7 @@ function findWiderAncestor(el: HTMLElement): HTMLElement | null { function applyExtension(wrapper: HTMLDivElement) { const wrapperRect = wrapper.getBoundingClientRect(); + if (wrapperRect.width === 0) return; const wider = findWiderAncestor(wrapper); if (!wider) { wrapper.style.setProperty("--embed-shift", "0px"); @@ -45,6 +46,7 @@ function applyExtension(wrapper: HTMLDivElement) { export function BaseEmbedView({ node }: NodeViewProps) { const pageId = node.attrs.pageId as string | null; const wrapperRef = useRef(null); + const { isLoading, isError } = useBaseQuery(pageId ?? ""); useEffect(() => { const wrapper = wrapperRef.current; @@ -63,44 +65,35 @@ export function BaseEmbedView({ node }: NodeViewProps) { ro.disconnect(); window.removeEventListener("resize", update); }; - }, []); + }, [isLoading, isError, pageId]); + let content: React.ReactNode; if (!pageId) { - return ( - - - Invalid base embed (missing page id) - - + content = ( + + Invalid base embed (missing page id) + ); - } - - const { isLoading, isError } = useBaseQuery(pageId); - - if (isLoading) { - return ( - - - Loading... - - + } else if (isLoading) { + content = ( + + Loading... + ); - } - - if (isError) { - return ( - - - You don't have access to this database. - - + } else if (isError) { + content = ( + + You don't have access to this database. + ); + } else { + content = ; } return (
- + {content}
);