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
This commit is contained in:
Zoltán Gilián
2019-08-02 08:30:43 -07:00
committed by Facebook Github Bot
parent ea8a6546c9
commit 1717fba410

View File

@@ -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;