fix: exclude Shift and Alt from sidebar keyboard shortcut#11158
Open
Emran-Y wants to merge 1 commit into
Open
Conversation
Contributor
|
@Emran-Y is attempting to deploy a commit to the shadcn-pro Team on Vercel. A member of the Team first needs to authorize it. |
|
Re-opening from the correct fork |
The SidebarProvider registers a global keyboard shortcut for toggling the sidebar with Cmd+B / Ctrl+B. Previously, the handler only checked for the 'b' key with metaKey/ctrlKey, but did not exclude Shift and Alt. This caused Cmd+Shift+B (a browser keyboard shortcut in many browsers) or Cmd+Alt+B to also trigger the sidebar toggle. For example, Shift+B with Cmd/Ctrl would redirect to the browser's bookmarks manager in most Chromium-based browsers, but the sidebar handler would intercept and block it via . This fix adds to ensure only the plain Cmd+B / Ctrl+B combination toggles the sidebar. Fixes: shadcn-ui#11104 Signed-off-by: Emran <emranyonas602@gmail.com>
Emran-Y
force-pushed
the
fix/sidebar-keyboard-shortcut-no-shift-alt
branch
from
July 14, 2026 07:46
bde474e to
9f11f0f
Compare
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.
Description
The
SidebarProviderregisters a global keyboard shortcut for toggling the sidebar withCmd+B/Ctrl+B. The current matching logic only checksevent.key === 'b' && (event.metaKey || event.ctrlKey).It does not exclude additional modifier keys like
ShiftorAlt. As a result,Cmd+Shift+B(a browser-level shortcut in many browsers) orCmd+Alt+Balso trigger the sidebar toggle, andevent.preventDefault()blocks the browser's default behavior.Fix
Added
!event.shiftKey && !event.altKeyto the condition, so only the plainCmd+B/Ctrl+Bcombination toggles the sidebar.Changes
Updated all 18 sidebar style variants across
apps/v4/styles/:Fixes #11104