Skip to content

refactor(navItem): "correctly" disabling links#24

Open
mfranzke wants to merge 2 commits intomainfrom
23-disabled-nav-item-is-selectable
Open

refactor(navItem): "correctly" disabling links#24
mfranzke wants to merge 2 commits intomainfrom
23-disabled-nav-item-is-selectable

Conversation

@mfranzke
Copy link
Copy Markdown
Contributor

@mfranzke mfranzke commented Jan 29, 2026

Correctly "disabling" links in db-nav-item components. We shouldn't disable a non-interactive, purely structural element (list-item), but the links directly.

@mfranzke mfranzke linked an issue Jan 29, 2026 that may be closed by this pull request
7 tasks
@mfranzke mfranzke self-assigned this Jan 29, 2026
@mfranzke mfranzke added the bug Something isn't working label Jan 29, 2026
@mfranzke mfranzke moved this from 🏗 In progress to 🎁 Ready for review in UX Engineering Team Backlog Jan 29, 2026
@mfranzke mfranzke requested a review from Copilot January 29, 2026 16:23
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the disabled link handling in navigation items by moving accessibility attributes from the DBNavigationItem component to the inner <a> element. The changes add tabindex and aria-disabled attributes to anchor tags when links are disabled.

Changes:

  • Moved aria-disabled attribute from DBNavigationItem to the child <a> element
  • Added tabindex="-1" to the <a> element when disabled to prevent keyboard navigation

Comment on lines 30 to 36
<a
href={trimExtension(target)}
aria-current={isActive ? 'page' : undefined}
data-icon-trailing={iconTrailing}
tabindex={disabled ? '-1' : undefined}
aria-disabled={disabled ? 'true' : undefined}
>
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

When a link is disabled, it should not be navigable via click. Consider adding an onClick handler that prevents navigation when disabled, or use CSS pointer-events to prevent interaction. Without this, users can still navigate to the disabled link by clicking on it, defeating the purpose of disabling it.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot is right. Just adding aria-disabled and tabIndex doesn't prevent clicks from triggering navigation. One fix is to conditionally remove the href when disabled (e.g., href={disabled ? undefined : path}).

Comment on lines 66 to 72
<a
href={trimExtension(path)}
aria-current={getAriaCurrent(trimExtension(path))}
data-icon-trailing={iconTrailing}
tabindex={disabled ? '-1' : undefined}
aria-disabled={disabled ? 'true' : undefined}
>
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

When a link is disabled, it should not be navigable via click. Consider adding an onClick handler that prevents navigation when disabled, or use CSS pointer-events to prevent interaction. Without this, users can still navigate to the disabled link by clicking on it, defeating the purpose of disabling it.

Copilot uses AI. Check for mistakes.
href={trimExtension(target)}
aria-current={isActive ? 'page' : undefined}
data-icon-trailing={iconTrailing}
tabindex={disabled ? '-1' : undefined}
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Suggested change
tabindex={disabled ? '-1' : undefined}
tabIndex={disabled ? '-1' : undefined}

In React/JSX, the attribute should be tabIndex (camelCase) instead of tabindex (lowercase). React will issue a warning about this in the console, and the lowercase version may not work correctly in all scenarios.

Copilot uses AI. Check for mistakes.
href={trimExtension(path)}
aria-current={getAriaCurrent(trimExtension(path))}
data-icon-trailing={iconTrailing}
tabindex={disabled ? '-1' : undefined}
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Suggested change
tabindex={disabled ? '-1' : undefined}
tabIndex={disabled ? '-1' : undefined}

In React/JSX, the attribute should be tabIndex (camelCase) instead of tabindex (lowercase). React will issue a warning about this in the console, and the lowercase version may not work correctly in all scenarios.

Copilot uses AI. Check for mistakes.
@mfranzke mfranzke enabled auto-merge (squash) January 29, 2026 16:27
@mfranzke mfranzke moved this from 🎁 Ready for review to 🏗 In progress in UX Engineering Team Backlog Jan 30, 2026
@michaelmkraus michaelmkraus changed the title refactor(navItem): "correctly" disabling links [X] - refactor(navItem): "correctly" disabling links Mar 19, 2026
@mfranzke mfranzke changed the title [X] - refactor(navItem): "correctly" disabling links refactor(navItem): "correctly" disabling links Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working nice to have

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

Disabled Nav Item is selectable

3 participants