fix(nav): release rapid-push guard when the push throws

This commit is contained in:
Gauvain
2026-07-17 17:42:34 +02:00
parent 1f7d24d63f
commit 4f03d7af3c

View File

@@ -55,19 +55,26 @@ export function useAppRouter() {
return;
pushInFlightRef.current = true;
}
if (typeof href === "string") {
router.push(href as any);
} else {
const callerParams = (href.params ?? {}) as Record<string, unknown>;
const hasExplicitOffline = "offline" in callerParams;
router.push({
...href,
params: {
// Only add offline if caller hasn't explicitly set it
...(isOffline && !hasExplicitOffline && { offline: "true" }),
...callerParams,
},
} as any);
try {
if (typeof href === "string") {
router.push(href as any);
} else {
const callerParams = (href.params ?? {}) as Record<string, unknown>;
const hasExplicitOffline = "offline" in callerParams;
router.push({
...href,
params: {
// Only add offline if caller hasn't explicitly set it
...(isOffline && !hasExplicitOffline && { offline: "true" }),
...callerParams,
},
} as any);
}
} catch (e) {
// A push that throws never blurs the screen, so the focus listener
// would never reset the guard — release it here to avoid a stuck lock.
pushInFlightRef.current = false;
throw e;
}
},
[router, isOffline, navigation],