Skip to content

Commit 65cfeef

Browse files
committed
fix(web): serialize location.search to prevent [object Object] in history
TanStack Router's useLocation() returns location.search as a parsed object, not a string. Concatenating it with strings caused JavaScript to call toString(), producing "[object Object]" in URLs and history. Use serializeSearch() utility (already used in NavigationTracker and use-user-interactions) to properly convert the search object to a query string format.
1 parent 4932de8 commit 65cfeef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

apps/web/src/hooks/useNavigationEnhancements.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
import { useLocation, useRouter } from "@tanstack/react-router";
77
import { useCallback, useEffect, useRef, useState } from "react";
88

9+
import { serializeSearch } from "@/utils/url-decoding";
10+
911
interface NavigationState {
1012
canGoBack: boolean;
1113
canGoForward: boolean;
@@ -20,7 +22,7 @@ export const useNavigationEnhancements = () => {
2022
const [searchHistory, setSearchHistory] = useState<string[]>([]);
2123

2224
// Track navigation history
23-
const currentPath = location.pathname + location.search + location.hash;
25+
const currentPath = location.pathname + serializeSearch(location.search) + location.hash;
2426

2527
useEffect(() => {
2628
const lastPath = historyRef.current[historyRef.current.length - 1];

0 commit comments

Comments
 (0)