Skip to content

Commit 3550bbd

Browse files
Copilotovertrue
andauthored
fix: breadcrumb navigation broken after page refresh in bucket browser (#97)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: overtrue <1472352+overtrue@users.noreply.github.com>
1 parent b17505a commit 3550bbd

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

components/top-nav-breadcrumb.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import * as React from "react"
44
import Link from "next/link"
5-
import { usePathname, useSearchParams } from "next/navigation"
5+
import { usePathname, useRouter, useSearchParams } from "next/navigation"
66
import { useTranslation } from "react-i18next"
77
import {
88
Breadcrumb,
@@ -26,6 +26,7 @@ function getLabelByPath(pathSegment: string, t: (k: string) => string): string {
2626
export function TopNavBreadcrumb() {
2727
const pathname = usePathname()
2828
const searchParams = useSearchParams()
29+
const router = useRouter()
2930
const { t } = useTranslation()
3031

3132
const segments = pathname?.split("/").filter(Boolean) ?? []
@@ -98,7 +99,15 @@ export function TopNavBreadcrumb() {
9899
<BreadcrumbItem>
99100
{item.href ? (
100101
<BreadcrumbLink asChild>
101-
<Link href={item.href}>{item.label}</Link>
102+
<Link
103+
href={item.href}
104+
onClick={(e) => {
105+
e.preventDefault()
106+
if (item.href) router.push(item.href)
107+
}}
108+
>
109+
{item.label}
110+
</Link>
102111
</BreadcrumbLink>
103112
) : (
104113
<BreadcrumbPage>{item.label}</BreadcrumbPage>

0 commit comments

Comments
 (0)