Skip to content

Commit fdaeba6

Browse files
committed
fix: Make documentation link open in new tab
- Update Sidebar to handle external links properly - Documentation link now opens /docs in new tab with external icon - Update TopNav dropdown to also open docs in new tab - Prevents dashboard context loss when viewing docs
1 parent 7261ec8 commit fdaeba6

2 files changed

Lines changed: 54 additions & 22 deletions

File tree

frontend/src/components/dashboard/Sidebar.tsx

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ interface NavItem {
4747
name: string
4848
href: string
4949
icon: React.ReactNode
50+
external?: boolean
5051
}
5152

5253
const mainNavItems: NavItem[] = [
@@ -55,7 +56,7 @@ const mainNavItems: NavItem[] = [
5556
]
5657

5758
const bottomNavItems: NavItem[] = [
58-
{ name: 'Documentation', href: '/docs', icon: <DocsIcon /> },
59+
{ name: 'Documentation', href: '/docs', icon: <DocsIcon />, external: true },
5960
{ name: 'Settings', href: '/dashboard/settings', icon: <SettingsIcon /> },
6061
]
6162

@@ -70,23 +71,49 @@ export function Sidebar({ collapsed, onToggle }: SidebarProps) {
7071
return location.pathname === href
7172
}
7273

73-
const NavLink = ({ item }: { item: NavItem }) => (
74-
<Link
75-
to={item.href}
76-
className={`flex items-center gap-3 px-3 py-2.5 rounded-lg transition-all group ${
77-
isActive(item.href)
78-
? 'bg-blue-500/10 text-blue-400'
79-
: 'text-gray-400 hover:text-white hover:bg-white/5'
80-
}`}
81-
>
82-
<span className={`${isActive(item.href) ? 'text-blue-400' : 'text-gray-500 group-hover:text-gray-300'}`}>
83-
{item.icon}
84-
</span>
85-
{!collapsed && (
86-
<span className="text-sm font-medium truncate">{item.name}</span>
87-
)}
88-
</Link>
89-
)
74+
const NavLink = ({ item }: { item: NavItem }) => {
75+
// External links open in new tab
76+
if (item.external) {
77+
return (
78+
<a
79+
href={item.href}
80+
target="_blank"
81+
rel="noopener noreferrer"
82+
className="flex items-center gap-3 px-3 py-2.5 rounded-lg transition-all group text-gray-400 hover:text-white hover:bg-white/5"
83+
>
84+
<span className="text-gray-500 group-hover:text-gray-300">
85+
{item.icon}
86+
</span>
87+
{!collapsed && (
88+
<>
89+
<span className="text-sm font-medium truncate">{item.name}</span>
90+
<svg className="w-3 h-3 ml-auto opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
91+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
92+
</svg>
93+
</>
94+
)}
95+
</a>
96+
)
97+
}
98+
99+
return (
100+
<Link
101+
to={item.href}
102+
className={`flex items-center gap-3 px-3 py-2.5 rounded-lg transition-all group ${
103+
isActive(item.href)
104+
? 'bg-blue-500/10 text-blue-400'
105+
: 'text-gray-400 hover:text-white hover:bg-white/5'
106+
}`}
107+
>
108+
<span className={`${isActive(item.href) ? 'text-blue-400' : 'text-gray-500 group-hover:text-gray-300'}`}>
109+
{item.icon}
110+
</span>
111+
{!collapsed && (
112+
<span className="text-sm font-medium truncate">{item.name}</span>
113+
)}
114+
</Link>
115+
)
116+
}
90117

91118
return (
92119
<aside

frontend/src/components/dashboard/TopNav.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,18 @@ export function TopNav({ onToggleSidebar, sidebarCollapsed, onOpenCommandPalette
112112
>
113113
Settings
114114
</Link>
115-
<Link
116-
to="/docs"
117-
className="block px-4 py-2 text-sm text-gray-300 hover:bg-white/5 transition-colors"
115+
<a
116+
href="/docs"
117+
target="_blank"
118+
rel="noopener noreferrer"
119+
className="flex items-center justify-between px-4 py-2 text-sm text-gray-300 hover:bg-white/5 transition-colors"
118120
onClick={() => setShowUserMenu(false)}
119121
>
120122
Documentation
121-
</Link>
123+
<svg className="w-3 h-3 opacity-50" fill="none" stroke="currentColor" viewBox="0 0 24 24">
124+
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
125+
</svg>
126+
</a>
122127
</div>
123128
<div className="border-t border-white/5 py-1">
124129
<button

0 commit comments

Comments
 (0)