Skip to content
This repository was archived by the owner on Aug 6, 2026. It is now read-only.

fix(terminal): stop Cmd+K clear from opening the command menu - #3436

Merged
charlesvien merged 1 commit into
mainfrom
posthog-code/terminal-cmdk-stop-command-menu
Jul 14, 2026
Merged

fix(terminal): stop Cmd+K clear from opening the command menu#3436
charlesvien merged 1 commit into
mainfrom
posthog-code/terminal-cmdk-stop-command-menu

Conversation

@posthog

@posthog posthog Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Problem

Pressing Cmd+K to clear the terminal also popped the command menu open on top, every time. Two independent mod+k handlers fired on a single keypress: the terminal's xterm handler cleared the terminal but only called preventDefault(), so the native keydown kept bubbling up to the document-level mod+k hotkey, which toggled the command palette open. The global binding had no terminal-focus guard.

Changes

Add stopPropagation() / stopImmediatePropagation() to the k + cmdOrCtrl branch of the terminal's custom key handler, so a terminal clear no longer reaches the global command-menu hotkey. The w, r, and 1-9 branches intentionally return false so their events do bubble to global handlers (close tab, reload, switch tabs), so they're deliberately left untouched.

How did you test this?

Added unit tests to TerminalManager.test.ts covering the key handler: Ctrl+K clears the terminal and calls preventDefault/stopPropagation/stopImmediatePropagation, while Ctrl+W keeps bubbling. Ran the suite — all 6 tests pass (pnpm --filter @posthog/ui test src/features/terminal/TerminalManager.test.ts). Biome lint clean on the changed files.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code from an inbox report.

The terminal's custom key handler cleared the terminal on Cmd/Ctrl+K but
only called preventDefault(), so the native keydown kept bubbling to the
document-level mod+k hotkey, which opened the command menu on every clear.

Add stopPropagation()/stopImmediatePropagation() in the k branch only. The
w/r/1-9 branches intentionally return false so their events bubble to the
global handlers, so they are left untouched.

Generated-By: PostHog Code
Task-Id: af84822e-2140-4b7d-8b01-2df4f2bff502
@trunk-io

trunk-io Bot commented Jul 14, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit e380a2d.

@charlesvien
charlesvien marked this pull request as ready for review July 14, 2026 18:14
@charlesvien
charlesvien merged commit 5a8351f into main Jul 14, 2026
29 checks passed
@charlesvien
charlesvien deleted the posthog-code/terminal-cmdk-stop-command-menu branch July 14, 2026 18:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant