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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user