Browse Source

feat: warn before closing tab with unsaved workflow changes

Add beforeunload handler that prompts the user when they try to close
the tab or navigate away while there are unsaved changes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 4 months ago
parent
commit
4865422ddc
  1. 10
      src/app/page.tsx

10
src/app/page.tsx

@ -19,6 +19,16 @@ export default function Home() {
return () => cleanupAutoSave();
}, [initializeAutoSave, cleanupAutoSave]);
useEffect(() => {
const handleBeforeUnload = (e: BeforeUnloadEvent) => {
if (useWorkflowStore.getState().hasUnsavedChanges) {
e.preventDefault();
}
};
window.addEventListener("beforeunload", handleBeforeUnload);
return () => window.removeEventListener("beforeunload", handleBeforeUnload);
}, []);
return (
<ReactFlowProvider>
<div className="h-screen flex flex-col">

Loading…
Cancel
Save