Skip to content

Remove the href from disabled TopNav items (#408) - #435

Merged
czarandy merged 1 commit into
mainfrom
worktree-issue-408-topnav-disabled-href
Aug 5, 2026
Merged

Remove the href from disabled TopNav items (#408)#435
czarandy merged 1 commit into
mainfrom
worktree-issue-408-topnav-disabled-href

Conversation

@czarandy

@czarandy czarandy commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Fixes #408

Problem

TopNavItem passed href unconditionally, even when disabled. The existing mitigations — aria-disabled, tabIndex={-1}, and an onClick preventDefault — don't remove the link: middle-click and "Open link in new tab" bypass the React click guard entirely and navigate to the disabled destination.

This also made TopNav the outlier in the library: Link and SideNavItem both null the href when disabled.

Fix

href={isDisabled ? undefined : href}, and drop target/rel alongside it (they are meaningless without an href, and this matches Link). The anchor still renders with aria-disabled and tabIndex={-1} as before, so nothing else about the rendered output changes.

Tests

Added a regression test asserting a disabled item's anchor has no href, target, or rel attribute. The disabled TopNav items in the existing Storybook story cover this visually.

https://claude.ai/code/session_01XFkkvUQfynGRedEYDNxKoY

A disabled TopNavItem still rendered a live href, so middle-click and "Open link in new tab" bypassed the React click guard and navigated to the disabled destination.

Null the href (plus target/rel) when disabled, matching Link and SideNavItem. The anchor still renders, with aria-disabled and tabIndex -1 as before.

Claude-Session: https://claude.ai/code/session_01XFkkvUQfynGRedEYDNxKoY
@vercel

vercel Bot commented Aug 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
silver-ui-site Ready Ready Preview Aug 5, 2026 10:52pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
silver-ui Ignored Ignored Preview Aug 5, 2026 10:52pm

@czarandy
czarandy enabled auto-merge (squash) August 5, 2026 22:53
@czarandy
czarandy merged commit 7722b40 into main Aug 5, 2026
4 checks passed
@czarandy
czarandy deleted the worktree-issue-408-topnav-disabled-href branch August 5, 2026 22:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disabled TopNav items keep a live href

1 participant