From 1717fba4107a3181bc5de476a763584ec9489ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Gili=C3=A1n?= Date: Fri, 2 Aug 2019 08:30:43 -0700 Subject: [PATCH] Add option to disable keyboard navigation in ManagedTable Summary: This may be needed e.g. if there are multiple ManagedTables in the window. Reviewed By: jknoxville, danielbuechele Differential Revision: D16620862 fbshipit-source-id: 1880e9e6e8e9ece5f687b2768eae7c4f206f69da --- src/ui/components/table/ManagedTable.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ui/components/table/ManagedTable.js b/src/ui/components/table/ManagedTable.js index d71232aef..88b57ca7a 100644 --- a/src/ui/components/table/ManagedTable.js +++ b/src/ui/components/table/ManagedTable.js @@ -130,6 +130,10 @@ export type ManagedTableProps = {| * Table scroll horizontally, if needed */ horizontallyScrollable?: boolean, + /** + * Whether to allow navigation via arrow keys. Default: true + */ + enableKeyboardNavigation?: boolean, |}; type ManagedTableState = {| @@ -155,6 +159,7 @@ class ManagedTable extends React.Component< highlightableRows: true, multiHighlight: false, autoHeight: false, + enableKeyboardNavigation: true, }; getTableKey = (): string => { @@ -304,7 +309,8 @@ class ManagedTable extends React.Component< this.onCopy(false); } else if ( (e.keyCode === 38 || e.keyCode === 40) && - this.props.highlightableRows + this.props.highlightableRows && + this.props.enableKeyboardNavigation ) { // arrow navigation const {rows} = this.props;