From 8c4e373dfccf80bc9c17e223c5316cd76f1e0476 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Thu, 30 May 2019 02:32:13 -0700 Subject: [PATCH] fix table context menu/drag-select Summary: As seen [here](https://fb.workplace.com/groups/230455004101832/permalink/623364598144202/?comment_id=623436418137020&comment_tracking=%7B%22tn%22%3A%22R%22%7D) using the primary key + CTRL to open the context menu, triggers the drag-select mode. This should not be the case. This diff changes the behaviour to: - Not trigger the drag-select-mode, when openting the context menu using CTRL - Select the current row, when performing a context click on it. Reviewed By: jknoxville Differential Revision: D15538057 fbshipit-source-id: d3d086c3d44618b2801e3a9b0646689c04fa32ff --- src/ui/components/table/ManagedTable.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/ui/components/table/ManagedTable.js b/src/ui/components/table/ManagedTable.js index 078c28c62..2219ba11b 100644 --- a/src/ui/components/table/ManagedTable.js +++ b/src/ui/components/table/ManagedTable.js @@ -372,11 +372,6 @@ class ManagedTable extends React.Component< row: TableBodyRow, index: number, ) => { - if (e.button !== 0 || !this.props.highlightableRows) { - // Only highlight rows when using primary mouse button, - // otherwise do nothing, to not interfere context menus. - return; - } if (e.shiftKey) { // prevents text selection e.preventDefault(); @@ -384,11 +379,18 @@ class ManagedTable extends React.Component< let {highlightedRows} = this.state; - this.dragStartIndex = index; - document.addEventListener('mouseup', this.onStopDragSelecting); + const contextClick = + e.button !== 0 || + (process.platform === 'darwin' && e.button === 0 && e.ctrlKey); + + if (!contextClick) { + this.dragStartIndex = index; + document.addEventListener('mouseup', this.onStopDragSelecting); + } if ( - ((e.metaKey && process.platform === 'darwin') || e.ctrlKey) && + ((process.platform === 'darwin' && e.metaKey) || + (process.platform !== 'darwin' && e.ctrlKey)) && this.props.multiHighlight ) { highlightedRows.add(row.key);