Skip to content

Commit 83d3b04

Browse files
jackfranklinDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
Allow deselecting data grid rows with Meta or Ctrl-click
And leave a big comment about why we have to gate this behaviour and why changing it is really hard. Bug: 409474445 Change-Id: I83d6bffab56bda41ba648015f74d6b6746865686 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6445881 Reviewed-by: Ergün Erdoğmuş <ergunsh@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org> Auto-Submit: Jack Franklin <jacktfranklin@chromium.org>
1 parent 140bef1 commit 83d3b04

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

front_end/ui/legacy/components/data_grid/DataGrid.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
/* eslint-disable rulesdir/no-imperative-dom-api */
2929

3030
import * as Common from '../../../../core/common/common.js';
31+
import * as Host from '../../../../core/host/host.js';
3132
import * as i18n from '../../../../core/i18n/i18n.js';
3233
import * as Platform from '../../../../core/platform/platform.js';
3334
import * as VisualLogging from '../../../visual_logging/visual_logging.js';
@@ -1375,7 +1376,20 @@ export class DataGridImpl<T> extends Common.ObjectWrapper.ObjectWrapper<EventTyp
13751376
return;
13761377
}
13771378

1378-
if ((event as MouseEvent).metaKey) {
1379+
/**
1380+
* Support Meta-Click (Cmd/Alt) or Ctrl-Click to toggle; if the row is
1381+
* selected we will then deselect it. You might think: why do we even gate
1382+
* this behind an additional key?
1383+
* Well, we tried to change that, but there are instances where we have
1384+
* multiple click handlers on a row, and so we cannot rely on select() only
1385+
* being called once. Sometimes by the time this event listener gets called,
1386+
* another click() handler has already marked this node as selected, so if
1387+
* we deselect it here, we are making the user unable to actually select a
1388+
* node. See crbug.com/409474445 for some cotext
1389+
*/
1390+
const mouseEvent = event as MouseEvent;
1391+
const modifier = Host.Platform.platform() === 'mac' ? mouseEvent.metaKey : mouseEvent.ctrlKey;
1392+
if (modifier) {
13791393
if (gridNode.selected) {
13801394
gridNode.deselect();
13811395
} else {

0 commit comments

Comments
 (0)