docs(canvas): explain recovery and import UI lifecycle

This commit is contained in:
2026-11-12 16:27:01 +08:00
parent 97fefaa519
commit d2068d416a
4 changed files with 13 additions and 0 deletions
+1
View File
@@ -11,6 +11,7 @@ export function DraftRecovery({ restore, discard, canRestore = true, exportDraft
const dialog = useRef<HTMLDialogElement>(null);
// 挂载时showModal启用浏览器模态行为,卸载时close;不额外保存一份open状态。
useEffect(() => { const element = dialog.current; element?.showModal(); return () => element?.close(); }, []);
// 点击按钮只同步调用宿主,不自动 close,也没有 busy/重复点击互斥;宿主完成选择后负责卸载对话框。
// 无document不创建Portal;取消事件阻止默认Escape关闭,要求用户通过明确的版本选择按钮处理。
if (typeof document === "undefined") return null;
return createPortal(<dialog ref={dialog} className={styles.recoveryDialog} aria-labelledby="draft-recovery-title" onCancel={(event) => event.preventDefault()}>