Skip to content

fix: exclude Shift and Alt from sidebar keyboard shortcut#11158

Open
Emran-Y wants to merge 1 commit into
shadcn-ui:mainfrom
Emran-Y:fix/sidebar-keyboard-shortcut-no-shift-alt
Open

fix: exclude Shift and Alt from sidebar keyboard shortcut#11158
Emran-Y wants to merge 1 commit into
shadcn-ui:mainfrom
Emran-Y:fix/sidebar-keyboard-shortcut-no-shift-alt

Conversation

@Emran-Y

@Emran-Y Emran-Y commented Jul 14, 2026

Copy link
Copy Markdown

Description

The SidebarProvider registers a global keyboard shortcut for toggling the sidebar with Cmd+B / Ctrl+B. The current matching logic only checks event.key === 'b' && (event.metaKey || event.ctrlKey).

It does not exclude additional modifier keys like Shift or Alt. As a result, Cmd+Shift+B (a browser-level shortcut in many browsers) or Cmd+Alt+B also trigger the sidebar toggle, and event.preventDefault() blocks the browser's default behavior.

Fix

Added !event.shiftKey && !event.altKey to the condition, so only the plain Cmd+B / Ctrl+B combination toggles the sidebar.

Changes

Updated all 18 sidebar style variants across apps/v4/styles/:

// Before
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
  (event.metaKey || event.ctrlKey)

// After
event.key === SIDEBAR_KEYBOARD_SHORTCUT &&
  (event.metaKey || event.ctrlKey) &&
  !event.shiftKey && !event.altKey

Fixes #11104

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown
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.

@emranyonas

Copy link
Copy Markdown

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
Emran-Y force-pushed the fix/sidebar-keyboard-shortcut-no-shift-alt branch from bde474e to 9f11f0f Compare July 14, 2026 07:46
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.

[bug]: SidebarProvider registers a global keyboard shortcut for toggling the sidebar with Cmd+B / Ctrl+B

2 participants