Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions components/top-nav-breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) ?? []
Expand Down Expand Up @@ -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)
}}
Comment on lines +104 to +107
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve native new-tab behavior for breadcrumb links

The new onClick handler always calls e.preventDefault() and router.push(...), which overrides native link behavior for modified clicks (Cmd/Ctrl-click, Shift-click, middle-click). In the breadcrumb this means users can no longer open an item in a new tab/window, and the current tab navigates unexpectedly instead; this is a functional regression introduced by the change. Consider only intercepting plain left-clicks and letting default browser behavior handle modified clicks.

Useful? React with 👍 / 👎.

>
{item.label}
</Link>
</BreadcrumbLink>
) : (
<BreadcrumbPage>{item.label}</BreadcrumbPage>
Expand Down
Loading