Skip to content

fix(web): handle sidebar shortcut before editors#3921

Open
Bortlesboat wants to merge 1 commit into
pingdotgg:mainfrom
Bortlesboat:fix/3833-sidebar-shortcut
Open

fix(web): handle sidebar shortcut before editors#3921
Bortlesboat wants to merge 1 commit into
pingdotgg:mainfrom
Bortlesboat:fix/3833-sidebar-shortcut

Conversation

@Bortlesboat

@Bortlesboat Bortlesboat commented Jul 12, 2026

Copy link
Copy Markdown

Summary

  • register the global sidebar shortcut handler in the capture phase
  • resolve configured sidebar commands before a focused rich-text editor consumes Mod+B
  • preserve the existing preventDefault/stopPropagation behavior after a match

Closes #3833

Verification

  • pnpm exec vp check (0 errors; existing unrelated warnings only)
  • pnpm exec vp run typecheck (all 15 workspaces passed; existing suggestions only)
  • git diff --check

Note

Low Risk
Single listener option change in one component; behavior is narrower (sidebar shortcut wins earlier) with no auth or data impact.

Overview
Fixes ⌘/Ctrl+B toggling the main sidebar when a rich-text editor is focused, where the same chord was being consumed for bold formatting instead.

The global sidebar.toggle handler in SidebarControl now registers keydown in the capture phase (addEventListener(..., true)), so configured shortcuts are resolved and can preventDefault / stopPropagation before focused editors see the event. Cleanup uses the same capture flag.

Reviewed by Cursor Bugbot for commit 5fa8008. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix sidebar toggle shortcut to intercept keydown events before focused editors

The SidebarControl keydown listener in AppSidebarLayout.tsx now registers in the capture phase (true passed to addEventListener/removeEventListener), so Mod+B is handled by the sidebar before focused editors consume it.

Macroscope summarized 5fa8008.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 39aa2392-75ca-46a4-afd3-247a7806e14f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Jul 12, 2026

@cursor cursor Bot left a comment

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.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5fa8008. Configure here.

return () => window.removeEventListener("keydown", onKeyDown);
// Capture before focused editors consume commands such as Mod+B for rich-text formatting.
window.addEventListener("keydown", onKeyDown, true);
return () => window.removeEventListener("keydown", onKeyDown, true);

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.

Capture blocks keybinding recording

Low Severity

Registering the sidebar shortcut on window in the capture phase makes it run before focused elements receive keydown. On keybindings settings, pressing the chord currently assigned to sidebar.toggle (default mod+b) toggles the sidebar and stops propagation, so the recording Input never records that press.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5fa8008. Configure here.

@macroscopeapp

macroscopeapp Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs human review

This PR changes keyboard event handling from bubble to capture phase. An unresolved review comment identifies that this may break keybinding recording functionality, as the sidebar toggle will intercept events before the recording input can capture them.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Sidebar doesn't close with keyboard shortcut when focusing chat box

1 participant