From d5ef6931d45d23de8a00cf169d03545d35f86cb8 Mon Sep 17 00:00:00 2001 From: abose Date: Tue, 17 Dec 2024 10:45:50 +0530 Subject: [PATCH] fix: ctrl-click in mac app and safari didnt open context menu --- src/brackets.js | 5 +++++ src/project/FileTreeView.js | 3 ++- src/widgets/bootstrap-dropdown.js | 10 +++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/brackets.js b/src/brackets.js index 4aa4456bb5..80ad195d78 100644 --- a/src/brackets.js +++ b/src/brackets.js @@ -470,6 +470,11 @@ define(function (require, exports, module) { // jQuery hides non-left clicks from such event handlers, yet middle-clicks still cause CEF to // navigate. Also, a capture handler is more reliable than bubble. window.document.body.addEventListener("click", function (e) { + // Don't interfere with context menu clicks + if (e.button === 2 || (brackets.platform === "mac" && e.ctrlKey)) { + return; + } + // Check parents too, in case link has inline formatting tags let node = e.target, url; while (node) { diff --git a/src/project/FileTreeView.js b/src/project/FileTreeView.js index fae45dd0b1..7c05bb9934 100644 --- a/src/project/FileTreeView.js +++ b/src/project/FileTreeView.js @@ -835,7 +835,8 @@ define(function (require, exports, module) { return; } - if (event.button !== LEFT_MOUSE_BUTTON) { + if (event.button !== LEFT_MOUSE_BUTTON + || (brackets.platform === "mac" && event.ctrlKey)) { // in mac ctrl-click is context menu return; } diff --git a/src/widgets/bootstrap-dropdown.js b/src/widgets/bootstrap-dropdown.js index a1d51519fe..80817915e2 100644 --- a/src/widgets/bootstrap-dropdown.js +++ b/src/widgets/bootstrap-dropdown.js @@ -156,7 +156,15 @@ * =================================== */ $(document) - .on('click.dropdown.data-api', clearMenus) + .on('click.dropdown.data-api', function(e) { + // Don't clear menus if this is a context menu click in mac/safari + // In Chrome, Ctrl+Click = context menu event and doesn't trigger the normal click handlers + // In Safari, Cmd+Click generates both a context menu event AND a regular click event so this check + if (e.button === 2 || (brackets.platform === "mac" && e.ctrlKey)) { + return; + } + clearMenus(); + }) .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) .on('click.dropdown-menu', function (e) { e.stopPropagation() }) .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)