fix: Prevent silent loss of changes in routing form when only one field exists (#25197)

This commit is contained in:
Mauryan Kansara
2025-11-18 02:02:57 +00:00
committed by GitHub
parent 358b873aa7
commit 02dab51543
@@ -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 system
const 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);