Skip to content

Conversation

@Varshil-B-Shah
Copy link

Summary

  • Fixed Ctrl+C copy command triggering when command menu dialog is closed
  • Added useRef to track dialog open state without causing infinite loops
  • Prevented unintended copying of last selected items from closed dialog

Problem

The command menu’s keyboard listener for Ctrl+C was executing even when the dialog was closed, causing the previously selected item to be copied despite the dialog being closed.

// Before (listener doesn't check if dialog is open)
if (e.key === "c" && (e.metaKey || e.ctrlKey)) {
  runCommand(() => { ... })
}

// After (only copies when dialog is open)
if (e.key === "c" && (e.metaKey || e.ctrlKey) && openRef.current) {
  runCommand(() => { ... })
}

This issue was reported in #9242.

Files Changed

  • apps/v4/components/command-menu.tsx

Test Plan

  • Open command menu, select an item, close dialog, then press Ctrl+C on website on different content
  • Verify proper website selected content is copied

Fixes

Fixes #9242

@vercel
Copy link
Contributor

vercel bot commented Jan 2, 2026

@Varshil-B-Shah is attempting to deploy a commit to the shadcn-pro Team on Vercel.

A member of the Team first needs to authorize it.

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]: Searching breaks Copying in the page

1 participant