Warn on tab close when create-flow module or wizard edits have not been saved.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
adilallo
2026-08-31 11:00:40 -06:00
co-authored by Cursor
parent a820739d07
commit 7f67cc6271
19 changed files with 350 additions and 1 deletions
+22
View File
@@ -25,6 +25,28 @@ export function captureMethodCardCustomizeSnapshot<TDraft>(
};
}
/**
* True when a method-card create/customize modal is open with edits that
* are not yet persisted — the condition for a tab/window `beforeunload` guard.
*/
export function isMethodCardCustomizeUnloadBlocked<TDraft>(
modalOpen: boolean,
snapshot: MethodCardCustomizeSnapshot<TDraft> | null,
pendingDraft: TDraft | null,
draftFieldBlocks: CustomMethodCardFieldBlock[] | null,
headerDraft: MethodCardHeaderDraft | null,
): boolean {
if (!modalOpen || snapshot === null) {
return false;
}
return isMethodCardCustomizeSessionDirty(
snapshot,
pendingDraft,
draftFieldBlocks,
headerDraft,
);
}
export function isMethodCardCustomizeSessionDirty<TDraft>(
snapshot: MethodCardCustomizeSnapshot<TDraft>,
pendingDraft: TDraft | null,