mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 04:18:54 +00: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,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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user