Skip to content

Commit 5e6f5f2

Browse files
committed
fix: remove hash fragments when switching networks to prevent incorrect anchor links
1 parent 4309e6a commit 5e6f5f2

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

src/features/feeds/components/FeedList.tsx

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,6 @@ export const FeedList = ({
101101
const [selectedFeedCategories, setSelectedFeedCategories] = useQueryString("categories", [])
102102
const [currentPage, setCurrentPage] = useQueryString("page", "1")
103103

104-
// Update URL when network changes
105-
const updateNetworkInURL = (network: string) => {
106-
if (typeof window === "undefined") return
107-
108-
const params = new URLSearchParams(window.location.search)
109-
params.set("network", network)
110-
// Preserve the hash fragment if it exists
111-
const hashFragment = window.location.hash
112-
const newUrl = window.location.pathname + "?" + params.toString() + hashFragment
113-
window.history.replaceState({ path: newUrl }, "", newUrl)
114-
setCurrentNetwork(network)
115-
}
116-
117104
// Initialize all other states
118105
const [showCategoriesDropdown, setShowCategoriesDropdown] = useState<boolean>(false)
119106
const [showExtraDetails, setShowExtraDetails] = useState(false)
@@ -170,7 +157,12 @@ export const FeedList = ({
170157
// Network selection handler
171158
function handleNetworkSelect(chain: Chain) {
172159
if (!isStreams) {
173-
updateNetworkInURL(chain.page)
160+
const params = new URLSearchParams(window.location.search)
161+
params.set("network", chain.page)
162+
// Remove hash fragment when changing networks to avoid mismatched anchors
163+
const newUrl = window.location.pathname + "?" + params.toString()
164+
window.history.replaceState({ path: newUrl }, "", newUrl)
165+
setCurrentNetwork(chain.page)
174166
}
175167
setSearchValue("")
176168
setSelectedFeedCategories([])

0 commit comments

Comments
 (0)