refactor: replace button+navigate() with React Router NavLink in sidebar#3022
Draft
StarbirdTech wants to merge 1 commit intospacedriveapp:mainfrom
Draft
refactor: replace button+navigate() with React Router NavLink in sidebar#3022StarbirdTech wants to merge 1 commit intospacedriveapp:mainfrom
StarbirdTech wants to merge 1 commit intospacedriveapp:mainfrom
Conversation
Replace button+onClick+navigate() pattern with React Router NavLink components for sidebar navigation items. This improves accessibility (screen readers announce links instead of buttons), enables browser affordances (right-click copy link, status bar URL preview), and eliminates manual active-state detection boilerplate. - Make SidebarItem polymorphic: `to` prop renders NavLink with auto active state, omitting `to` renders button (for action items) - Convert explorer Sidebar, LocationsSection, and TagItem to use NavLink-based navigation - Add shouldNavigate() utility for button-based navigation that can't use NavLink (SpaceItem with dnd-kit, TopBarButton actions, etc.) - shouldNavigate() checks both e.button and modifier keys (meta, ctrl, shift, alt), replacing incomplete e.button !== 0 guards Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3008
Replaces the
<button onClick={() => navigate(path)}>pattern with React Router<NavLink>for sidebar navigation. The current pattern uses buttons for what are semantically links — screen readers announce "button" instead of "link", there's no right-click "Copy Link" or status bar URL preview, and every component manually reimplements active-state detection and click filtering.Changes
SidebarItemis now polymorphic — pass atoprop and it renders as<NavLink>with automatic active state and<a>tag semantics. Omittoand it renders as<button>for action items like "Add Location". This is the core of the refactor; everything else follows from it.Explorer sidebar, LocationsSection, and TagItem now use
toprop /<NavLink>directly, eliminatinguseNavigate(),useLocation(),isActive()helpers, and manual click guards from these components.shouldNavigate()utility for navigation that can't use<NavLink>— SpaceItem (dnd-kit sortable listeners on the element), TopBarButton expand/back actions, "Open Location" in the inspector. Replaces the incompletee.button !== 0guard with full modifier key checks (meta, ctrl, shift, alt).Not yet tested
I need to check several things on macOS and Windows such as:
/(testsendprop)<a>, action items as<button>