Skip to content

Connect, collaborate, and grow with a community of TypeScript developers

fix: Refreshing wizard causes loss of progress (#791)

Srinivasa IK Varanasi4185dc561848
diff --git a/apps/web/src/app/[locale]/wizard/_components/index.tsx b/apps/web/src/app/[locale]/wizard/_components/index.tsx
index 87dfc5bc..30564507 100644
--- a/apps/web/src/app/[locale]/wizard/_components/index.tsx
+++ b/apps/web/src/app/[locale]/wizard/_components/index.tsx
@@ -107,6 +107,18 @@ export function Wizard() {
useEffect(() => {
setRendered(true);
+
+ const handleBeforeUnload: EventListenerOrEventListenerObject = (event) => {
+ event.preventDefault();
+ event.returnValue = false;
+ };
+
+ window.addEventListener('beforeunload', handleBeforeUnload, { capture: true });
+
+ return () => {
+ // Clean up the event listener when the component unmounts
+ window.removeEventListener('beforeunload', handleBeforeUnload);
+ };
}, []);
const handleNextClick = async () => {