Scheduling infrastructure for absolutely everyone.
fix: Prevent silent loss of changes in routing form when only one field exists (#25197)
Mauryan Kansara02dab515435a
diff --git a/apps/web/components/apps/routing-forms/Header.tsx b/apps/web/components/apps/routing-forms/Header.tsxindex c32918736c9..3540a5057f3 100644--- a/apps/web/components/apps/routing-forms/Header.tsx+++ b/apps/web/components/apps/routing-forms/Header.tsx@@ -23,7 +23,7 @@ const useRoutingFormNavigation = () => {const pathname = usePathname();const router = useRouter();- const formContext = useFormContext<RoutingFormWithResponseCount>();+ const { isDirty } = useFormContext<RoutingFormWithResponseCount>().formState;// Get the current page based on the pathname since we use a custom routing systemconst getCurrentPage = () => {@@ -39,7 +39,7 @@ const useRoutingFormNavigation = (const baseUrl = `${appUrl}/${value}/${form.id}`;- if (value === "route-builder" && formContext.formState.isDirty) {+ if (value === "route-builder" && isDirty) {setShowInfoLostDialog(true);} else {router.push(baseUrl);