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
This commit is contained in:
committed by
Facebook Github Bot
parent
c94c2c8455
commit
8c4e373dfc
@@ -372,11 +372,6 @@ class ManagedTable extends React.Component<
|
|||||||
row: TableBodyRow,
|
row: TableBodyRow,
|
||||||
index: number,
|
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) {
|
if (e.shiftKey) {
|
||||||
// prevents text selection
|
// prevents text selection
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -384,11 +379,18 @@ class ManagedTable extends React.Component<
|
|||||||
|
|
||||||
let {highlightedRows} = this.state;
|
let {highlightedRows} = this.state;
|
||||||
|
|
||||||
this.dragStartIndex = index;
|
const contextClick =
|
||||||
document.addEventListener('mouseup', this.onStopDragSelecting);
|
e.button !== 0 ||
|
||||||
|
(process.platform === 'darwin' && e.button === 0 && e.ctrlKey);
|
||||||
|
|
||||||
|
if (!contextClick) {
|
||||||
|
this.dragStartIndex = index;
|
||||||
|
document.addEventListener('mouseup', this.onStopDragSelecting);
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
((e.metaKey && process.platform === 'darwin') || e.ctrlKey) &&
|
((process.platform === 'darwin' && e.metaKey) ||
|
||||||
|
(process.platform !== 'darwin' && e.ctrlKey)) &&
|
||||||
this.props.multiHighlight
|
this.props.multiHighlight
|
||||||
) {
|
) {
|
||||||
highlightedRows.add(row.key);
|
highlightedRows.add(row.key);
|
||||||
|
|||||||
Reference in New Issue
Block a user