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>
This commit is contained in:
Copilot
2026-04-10 08:43:58 +08:00
committed by GitHub
parent b17505adf7
commit 3550bbd487
+11 -2
View File
@@ -2,7 +2,7 @@
import * as React from "react"
import Link from "next/link"
import { usePathname, useSearchParams } from "next/navigation"
import { usePathname, useRouter, useSearchParams } from "next/navigation"
import { useTranslation } from "react-i18next"
import {
Breadcrumb,
@@ -26,6 +26,7 @@ function getLabelByPath(pathSegment: string, t: (k: string) => string): string {
export function TopNavBreadcrumb() {
const pathname = usePathname()
const searchParams = useSearchParams()
const router = useRouter()
const { t } = useTranslation()
const segments = pathname?.split("/").filter(Boolean) ?? []
@@ -98,7 +99,15 @@ export function TopNavBreadcrumb() {
<BreadcrumbItem>
{item.href ? (
<BreadcrumbLink asChild>
<Link href={item.href}>{item.label}</Link>
<Link
href={item.href}
onClick={(e) => {
e.preventDefault()
if (item.href) router.push(item.href)
}}
>
{item.label}
</Link>
</BreadcrumbLink>
) : (
<BreadcrumbPage>{item.label}</BreadcrumbPage>