mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-20 07:47:19 +08:00
fix: cannot read properties of undefined editor.host (#7333)
Fix issue [BS-657](https://linear.app/affine-design/issue/BS-657). Unable to obtain `editor.host` synchronously on `editor` reference callback. Maybe we should have a separate host reference callback. @pengx17 
This commit is contained in:
@@ -72,7 +72,8 @@ export function DocPeekPreview({
|
|||||||
const [resolvedMode, setResolvedMode] = useState<DocMode | undefined>(mode);
|
const [resolvedMode, setResolvedMode] = useState<DocMode | undefined>(mode);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (editor && resolvedMode === 'edgeless') {
|
requestAnimationFrame(() => {
|
||||||
|
if (editor && editor.host && resolvedMode === 'edgeless') {
|
||||||
editor.host
|
editor.host
|
||||||
.closest('[data-testid="peek-view-modal-animation-container"]')
|
.closest('[data-testid="peek-view-modal-animation-container"]')
|
||||||
?.addEventListener(
|
?.addEventListener(
|
||||||
@@ -85,6 +86,7 @@ export function DocPeekPreview({
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}, [editor, resolvedMode, xywh]);
|
}, [editor, resolvedMode, xywh]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user