Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: cannot read properties of undefined editor.host (#7333)

akumatus4df334bfdb9b
diff --git a/packages/frontend/core/src/modules/peek-view/view/doc-peek-view.tsx b/packages/frontend/core/src/modules/peek-view/view/doc-peek-view.tsx
index 20bc02c1dc..48e1d6d17e 100644
--- a/packages/frontend/core/src/modules/peek-view/view/doc-peek-view.tsx
+++ b/packages/frontend/core/src/modules/peek-view/view/doc-peek-view.tsx
@@ -72,19 +72,21 @@ export function DocPeekPreview({
const [resolvedMode, setResolvedMode] = useState<DocMode | undefined>(mode);
useEffect(() => {
- if (editor && resolvedMode === 'edgeless') {
- editor.host
- .closest('[data-testid="peek-view-modal-animation-container"]')
- ?.addEventListener(
- 'animationend',
- () => {
- fitViewport(editor, xywh);
- },
- {
- once: true,
- }
- );
- }
+ requestAnimationFrame(() => {
+ if (editor && editor.host && resolvedMode === 'edgeless') {
+ editor.host
+ .closest('[data-testid="peek-view-modal-animation-container"]')
+ ?.addEventListener(
+ 'animationend',
+ () => {
+ fitViewport(editor, xywh);
+ },
+ {
+ once: true,
+ }
+ );
+ }
+ });
return;
}, [editor, resolvedMode, xywh]);