1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Don't allow the middle mouse button to start an inline comment

Summary:
Ref T13216. See PHI985. When you click a line number to start an inline comment, we intend to initiate the action only if you used the left mouse button (desktop) or a touch (tablet/device).

We currently have a `not right` condition for doing this, but it only excludes right clicks, not middle clicks (or other nth-button clicks). The `not right` condition was sligthly easier to write, but use an `is left` condition instead of a `not right` condition.

Test Plan:
  - In Safari, Firefox and Chrome:
    - Used left click to start an inline.
    - Used middle click to do nothing (previously: started an inline).

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13216

Differential Revision: https://secure.phabricator.com/D19836
This commit is contained in:
epriestley 2018-11-24 06:59:19 -08:00
parent 5343b1f898
commit 8b550ce2cd
3 changed files with 31 additions and 14 deletions

View file

@ -10,9 +10,9 @@ return array(
'conpherence.pkg.css' => 'e68cf1fa',
'conpherence.pkg.js' => '15191c65',
'core.pkg.css' => 'cff4ff6f',
'core.pkg.js' => 'b5a949ca',
'core.pkg.js' => '4bde473b',
'differential.pkg.css' => '06dc617c',
'differential.pkg.js' => 'c1cfa143',
'differential.pkg.js' => 'ef0b989b',
'diffusion.pkg.css' => 'a2d17c7d',
'diffusion.pkg.js' => '6134c5a1',
'maniphest.pkg.css' => '4845691a',
@ -207,7 +207,7 @@ return array(
'rsrc/externals/font/lato/lato-regular.ttf' => 'e270165b',
'rsrc/externals/font/lato/lato-regular.woff' => '13d39fe2',
'rsrc/externals/font/lato/lato-regular.woff2' => '57a9f742',
'rsrc/externals/javelin/core/Event.js' => '2ee659ce',
'rsrc/externals/javelin/core/Event.js' => 'ef7e057f',
'rsrc/externals/javelin/core/Stratcom.js' => '327f418a',
'rsrc/externals/javelin/core/__tests__/event-stop-and-kill.js' => '717554e4',
'rsrc/externals/javelin/core/__tests__/install.js' => 'c432ee85',
@ -373,7 +373,7 @@ return array(
'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '453c5375',
'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => 'd4eecc63',
'rsrc/js/application/diff/DiffChangeset.js' => 'b49b59d6',
'rsrc/js/application/diff/DiffChangesetList.js' => 'e0b984b5',
'rsrc/js/application/diff/DiffChangesetList.js' => '0a84bcc1',
'rsrc/js/application/diff/DiffInline.js' => 'e83d28f3',
'rsrc/js/application/diff/behavior-preview-link.js' => '051c7832',
'rsrc/js/application/differential/behavior-comment-preview.js' => '51c5ad07',
@ -688,7 +688,7 @@ return array(
'javelin-diffusion-locate-file-source' => '00676f00',
'javelin-dom' => '4976858c',
'javelin-dynval' => 'f6555212',
'javelin-event' => '2ee659ce',
'javelin-event' => 'ef7e057f',
'javelin-fx' => '54b612ba',
'javelin-history' => 'd4505101',
'javelin-install' => '05270951',
@ -750,7 +750,7 @@ return array(
'phabricator-darkmessage' => 'c48cccdd',
'phabricator-dashboard-css' => 'fe5b1869',
'phabricator-diff-changeset' => 'b49b59d6',
'phabricator-diff-changeset-list' => 'e0b984b5',
'phabricator-diff-changeset-list' => '0a84bcc1',
'phabricator-diff-inline' => 'e83d28f3',
'phabricator-drag-and-drop-file-upload' => '58dea2fa',
'phabricator-draggable-list' => 'bea6e7f4',
@ -944,6 +944,10 @@ return array(
'javelin-dom',
'javelin-router',
),
'0a84bcc1' => array(
'javelin-install',
'phuix-button-view',
),
'0f764c35' => array(
'javelin-install',
'javelin-util',
@ -1049,9 +1053,6 @@ return array(
'javelin-install',
'javelin-event',
),
'2ee659ce' => array(
'javelin-install',
),
'31420f77' => array(
'javelin-behavior',
),
@ -2009,10 +2010,6 @@ return array(
'phuix-icon-view',
'phabricator-prefab',
),
'e0b984b5' => array(
'javelin-install',
'phuix-button-view',
),
'e1d25dfb' => array(
'javelin-behavior',
'javelin-stratcom',
@ -2094,6 +2091,9 @@ return array(
'javelin-behavior',
'javelin-uri',
),
'ef7e057f' => array(
'javelin-install',
),
'efe49472' => array(
'javelin-install',
'javelin-util',

View file

@ -133,6 +133,20 @@ JX.install('Event', {
return r.which == 3 || r.button == 2;
},
/**
* Get whether the mouse button associated with the mouse event is the
* left-side button in a browser-agnostic way.
*
* @return bool
* @task info
*/
isLeftButton: function() {
var r = this.getRawEvent();
return (r.which == 1 || r.button == 0);
},
/**
* Determine if a mouse event is a normal event (left mouse button, no
* modifier keys).

View file

@ -1261,7 +1261,10 @@ JX.install('DiffChangesetList', {
_onrangedown: function(e) {
// NOTE: We're allowing "mousedown" from a touch event through so users
// can leave inlines on a single line.
if (e.isRightButton()) {
// See PHI985. We want to exclude both right-mouse and middle-mouse
// clicks from continuing.
if (!e.isLeftButton()) {
return;
}