From 53c31b7b135cb17bd2d14169b81743931f1a6542 Mon Sep 17 00:00:00 2001 From: Valerio Bozzolan Date: Fri, 3 Mar 2023 12:12:01 +0100 Subject: [PATCH] Fix middle-click, CTRL+click, right-click etc. on Typehead search results Summary: Fix middle-click, CTRL+click, right-click etc. on Typehead search results. Closes T15149 Test Plan: Try the following actions on various typeheads: - right-click - middle-click - CTRL+click - normal click Demonstration video (2M) showing After patch (on localhost) and Before patch (here on we.phorge.it), where I middle-click and normal-click on menu entries: {F256610} Notes: - the middle click now works (opening in new tab) - the CTRL+click (or "command" key + click) now works (opening in new tab) - the right click now opens the context menu (previously broken) - the normal click should just click (as usual) Try on: - search results while typing in main search bar - search results when editing a Task Tags / assigned to, etc. - try to click on other weird places - $$$ Reviewers: O1 Blessed Committers, avivey Reviewed By: O1 Blessed Committers, avivey Subscribers: speck, tobiaswiese, Matthew, Cigaryno Maniphest Tasks: T15149 Differential Revision: https://we.phorge.it/D25069 --- resources/celerity/map.php | 18 +++++++++--------- .../javelin/lib/control/typeahead/Typeahead.js | 13 ++++++++++++- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 80ba37f78e..71761a45e6 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -10,7 +10,7 @@ return array( 'conpherence.pkg.css' => '0e3cf785', 'conpherence.pkg.js' => '020aebcf', 'core.pkg.css' => 'f538846d', - 'core.pkg.js' => '256dfd7b', + 'core.pkg.js' => '6a2c22c2', 'dark-console.pkg.js' => '187792c2', 'differential.pkg.css' => '609e63d4', 'differential.pkg.js' => 'c60bec1b', @@ -265,7 +265,7 @@ return array( 'rsrc/externals/javelin/lib/__tests__/behavior.js' => '8426ebeb', 'rsrc/externals/javelin/lib/behavior.js' => '1b6acc2a', 'rsrc/externals/javelin/lib/control/tokenizer/Tokenizer.js' => '89a1ae3a', - 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => 'a4356cde', + 'rsrc/externals/javelin/lib/control/typeahead/Typeahead.js' => 'd96e47a4', 'rsrc/externals/javelin/lib/control/typeahead/normalizer/TypeaheadNormalizer.js' => 'a241536a', 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadCompositeSource.js' => '22ee68a5', 'rsrc/externals/javelin/lib/control/typeahead/source/TypeaheadOnDemandSource.js' => '23387297', @@ -731,7 +731,7 @@ return array( 'javelin-sound' => 'd4cc2d2a', 'javelin-stratcom' => '0889b835', 'javelin-tokenizer' => '89a1ae3a', - 'javelin-typeahead' => 'a4356cde', + 'javelin-typeahead' => 'd96e47a4', 'javelin-typeahead-composite-source' => '22ee68a5', 'javelin-typeahead-normalizer' => 'a241536a', 'javelin-typeahead-ondemand-source' => '23387297', @@ -1800,12 +1800,6 @@ return array( 'javelin-workflow', 'phabricator-draggable-list', ), - 'a4356cde' => array( - 'javelin-install', - 'javelin-dom', - 'javelin-vector', - 'javelin-util', - ), 'a43ae2ae' => array( 'javelin-install', 'javelin-dom', @@ -2100,6 +2094,12 @@ return array( 'javelin-util', 'phabricator-shaped-request', ), + 'd96e47a4' => array( + 'javelin-install', + 'javelin-dom', + 'javelin-vector', + 'javelin-util', + ), 'da15d3dc' => array( 'phui-oi-list-view-css', ), diff --git a/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js b/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js index 5875bf9ea6..e971ae1495 100644 --- a/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js +++ b/webroot/rsrc/externals/javelin/lib/control/typeahead/Typeahead.js @@ -84,8 +84,19 @@ JX.install('Typeahead', { 'mousedown', 'tag:a', JX.bind(this, function(e) { - if (!e.isRightButton()) { + if (e.isNormalMouseEvent()) { this._choose(e.getNode('tag:a')); + } else { + // fix the middle-click and any non-normal mouse event + // in order to have an "open in a new tab" that just works natively + // or any other browser action that is supposed to be there. + // + // Probably this is one of the specific cases where kill() has + // sense instead of just stop(), since there are not much chances + // that another event listener had anything else to do + // during non-normal mousedown/click events. + // https://we.phorge.it/T15149 + e.kill(); } }));