From 062cbc0dbd4e634a468a81d989c0ee9a09d61e86 Mon Sep 17 00:00:00 2001 From: John Knox Date: Fri, 14 Jun 2019 09:10:55 -0700 Subject: [PATCH] Fix contextClick after multi-highlight Summary: Select multiple rows, and then right click, or use Ctrl-click. This was broken, it was resetting the selection when this happened. This fixes it. Now after selecting multiple, what happens depends where you right-click. If you right-click within the current selection, it stays selected and you can copy it. But if you right-click outside the current selection, that row becomes the new selected set, and you will just be able to copy that one. This feels right to me. Reviewed By: passy Differential Revision: D15822668 fbshipit-source-id: 6a6cda8a8f16fec55cffa52c1c2ff958c86b3f43 --- src/ui/components/table/ManagedTable.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/ui/components/table/ManagedTable.js b/src/ui/components/table/ManagedTable.js index 996bb4821..ff1a21bf1 100644 --- a/src/ui/components/table/ManagedTable.js +++ b/src/ui/components/table/ManagedTable.js @@ -383,11 +383,17 @@ class ManagedTable extends React.Component< e.button !== 0 || (process.platform === 'darwin' && e.button === 0 && e.ctrlKey); - if (!contextClick) { - this.dragStartIndex = index; - document.addEventListener('mouseup', this.onStopDragSelecting); + if (contextClick) { + if (!highlightedRows.has(row.key)) { + highlightedRows.clear(); + highlightedRows.add(row.key); + } + return; } + this.dragStartIndex = index; + document.addEventListener('mouseup', this.onStopDragSelecting); + if ( ((process.platform === 'darwin' && e.metaKey) || (process.platform !== 'darwin' && e.ctrlKey)) &&