Skip to content

Commit 458cc5e

Browse files
committed
fix: contextual awareness for close confirmation modal
1 parent f743d6e commit 458cc5e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

packages/imagekit-editor-dev/src/ImageKitEditor.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,13 @@ function ImageKitEditorImpl<M extends RequiredMetadata>(
148148
}, [resolvedProvider])
149149

150150
const handleOnClose = () => {
151-
const dirty = transformations.length > 0
151+
// `dirty` should represent *unsynced* changes (host uses it to decide
152+
// whether to show a close confirmation).
153+
const state = useEditorStore.getState()
154+
const hasChanges = !state.isPristine
155+
const dirty = resolvedProvider
156+
? hasChanges && state.syncStatus !== "saved"
157+
: hasChanges
152158
props.onClose({ dirty, destroy })
153159
}
154160

0 commit comments

Comments
 (0)