Skip to content

Commit 42f1a95

Browse files
author
epriestley
committedMay 14, 2020
Fix a flash of document selection when "oncopy" and "inline on range" behaviors interact
Summary: Ref T13513. In Safari, do this: - view a 2-up diff with content on both sides; - select more than one line on the right side; and - use your mouse to click "New Inline Comment" in the context menu that pops up. The mousedown event for the "New Inline Comment" click removes the "copy selection" behavior and creates a flash where both sides of the diff are selected. This doesn't happen with (most) normal clicks because mouse down on a non-grabbable element clears the document selection. To avoid this, don't reset the copy selection behavior if the user mouses down on an "<a />". This might not be robust, but seems simple and plausible as a fix. Test Plan: - See above. - Before patch: flash of overbroad selection when clicking "New Inline Comment". - After patch: no selection flash. Maniphest Tasks: T13513 Differential Revision: https://secure.phabricator.com/D21254
1 parent f45519c commit 42f1a95

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed
 

‎resources/celerity/map.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'conpherence.pkg.css' => '0e3cf785',
1111
'conpherence.pkg.js' => '020aebcf',
1212
'core.pkg.css' => 'a560707d',
13-
'core.pkg.js' => '0efaf0ac',
13+
'core.pkg.js' => '845355f4',
1414
'dark-console.pkg.js' => '187792c2',
1515
'differential.pkg.css' => 'b042ee8b',
1616
'differential.pkg.js' => '5d560bda',
@@ -488,7 +488,7 @@
488488
'rsrc/js/core/behavior-linked-container.js' => '74446546',
489489
'rsrc/js/core/behavior-more.js' => '506aa3f4',
490490
'rsrc/js/core/behavior-object-selector.js' => '98ef467f',
491-
'rsrc/js/core/behavior-oncopy.js' => 'b475aae5',
491+
'rsrc/js/core/behavior-oncopy.js' => 'da8f5259',
492492
'rsrc/js/core/behavior-phabricator-remarkup-assist.js' => '54262396',
493493
'rsrc/js/core/behavior-read-only-warning.js' => 'b9109f8f',
494494
'rsrc/js/core/behavior-redirect.js' => '407ee861',
@@ -648,7 +648,7 @@
648648
'javelin-behavior-phabricator-line-linker' => '590e6527',
649649
'javelin-behavior-phabricator-notification-example' => '29819b75',
650650
'javelin-behavior-phabricator-object-selector' => '98ef467f',
651-
'javelin-behavior-phabricator-oncopy' => 'b475aae5',
651+
'javelin-behavior-phabricator-oncopy' => 'da8f5259',
652652
'javelin-behavior-phabricator-remarkup-assist' => '54262396',
653653
'javelin-behavior-phabricator-reveal-content' => 'b105a3a6',
654654
'javelin-behavior-phabricator-search-typeahead' => '1cb7d027',
@@ -1952,10 +1952,6 @@
19521952
'javelin-workboard-card-template',
19531953
'javelin-workboard-order-template',
19541954
),
1955-
'b475aae5' => array(
1956-
'javelin-behavior',
1957-
'javelin-dom',
1958-
),
19591955
'b49fd60c' => array(
19601956
'multirow-row-manager',
19611957
'trigger-rule',
@@ -2116,6 +2112,10 @@
21162112
'da15d3dc' => array(
21172113
'phui-oi-list-view-css',
21182114
),
2115+
'da8f5259' => array(
2116+
'javelin-behavior',
2117+
'javelin-dom',
2118+
),
21192119
'dae2d55b' => array(
21202120
'javelin-behavior',
21212121
'javelin-uri',

‎webroot/rsrc/js/core/behavior-oncopy.js

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ JX.behavior('phabricator-oncopy', function() {
1111
function onstartselect(e) {
1212
var target = e.getTarget();
1313

14+
// See T13513. If the user selects multiple lines in a 2-up diff and then
15+
// clicks "New Inline Comment" in the context menu that pops up, the
16+
// mousedown causes us to arrive here and remove the "selectable" CSS
17+
// styles, and creates a flash of selected content across both sides of
18+
// the diff, which is distracting. To attempt to avoid this, bail out if
19+
// the user clicked a link.
20+
21+
if (JX.DOM.isType(target, 'a')) {
22+
return;
23+
}
24+
1425
var container;
1526
try {
1627
// NOTE: For now, all elements with custom oncopy behavior are tables,

0 commit comments

Comments
 (0)
Failed to load comments.