Skip to content

Commit 0e00f2b

Browse files
committed
fix: fixed controller back button
1 parent 2c9aaba commit 0e00f2b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

packages/keychain/src/context/navigation.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function NavigationProvider({
7676
lastTrackedPath.current = "/";
7777

7878
navigate("/", { replace: true });
79-
}, [navigate]);
79+
}, [navigate, setNavigationStack, setCurrentIndex]);
8080

8181
// Initialize with current location
8282
useEffect(() => {
@@ -92,7 +92,7 @@ export function NavigationProvider({
9292
lastTrackedPath.current = currentPath;
9393
isInitialized.current = true;
9494
}
95-
}, [getFullPath, location.state]);
95+
}, [getFullPath, location.state, setNavigationStack, setCurrentIndex]);
9696

9797
// Track location changes - fixed to avoid infinite loop
9898
useEffect(() => {
@@ -156,6 +156,11 @@ export function NavigationProvider({
156156
}
157157
}
158158

159+
// if equals to the last path, keep new one
160+
if (prev[currentPosition]?.path === newEntry.path) {
161+
currentPosition--;
162+
}
163+
159164
// Truncate any forward history and add new entry
160165
const newStack = [...prev.slice(0, currentPosition + 1), newEntry];
161166

0 commit comments

Comments
 (0)