Allow passing external virtualizedRef to DataTable
Summary: External virtualRef allows us to scroll the table programmatically whenever we want Reviewed By: antonk52 Differential Revision: D44746968 fbshipit-source-id: ad8e0fb3b43881ed8f4ba114cd35c08643ef0d3b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
f63ea1f9bd
commit
4e898eb01a
@@ -61,6 +61,8 @@ export {DataTableManager} from './ui/data-table/DataTableManager';
|
|||||||
export {DataList} from './ui/DataList';
|
export {DataList} from './ui/DataList';
|
||||||
export {Spinner} from './ui/Spinner';
|
export {Spinner} from './ui/Spinner';
|
||||||
|
|
||||||
|
export {DataSourceVirtualizer} from './data-source/DataSourceRendererVirtual';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
Interactive as _Interactive,
|
Interactive as _Interactive,
|
||||||
InteractiveProps as _InteractiveProps,
|
InteractiveProps as _InteractiveProps,
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ type DataTableBaseProps<T = any> = {
|
|||||||
onSelect?(record: T | undefined, records: T[]): void;
|
onSelect?(record: T | undefined, records: T[]): void;
|
||||||
onRowStyle?(record: T): CSSProperties | undefined;
|
onRowStyle?(record: T): CSSProperties | undefined;
|
||||||
tableManagerRef?: RefObject<DataTableManager<T> | undefined>; // Actually we want a MutableRefObject, but that is not what React.createRef() returns, and we don't want to put the burden on the plugin dev to cast it...
|
tableManagerRef?: RefObject<DataTableManager<T> | undefined>; // Actually we want a MutableRefObject, but that is not what React.createRef() returns, and we don't want to put the burden on the plugin dev to cast it...
|
||||||
|
virtualizerRef?: RefObject<DataSourceVirtualizer | undefined>;
|
||||||
onCopyRows?(records: T[]): string;
|
onCopyRows?(records: T[]): string;
|
||||||
onContextMenu?: (selection: undefined | T) => React.ReactElement;
|
onContextMenu?: (selection: undefined | T) => React.ReactElement;
|
||||||
onRenderEmpty?:
|
onRenderEmpty?:
|
||||||
@@ -159,7 +160,12 @@ export function DataTable<T extends object>(
|
|||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const scope = isUnitTest ? '' : usePluginInstanceMaybe()?.definition.id ?? '';
|
const scope = isUnitTest ? '' : usePluginInstanceMaybe()?.definition.id ?? '';
|
||||||
const virtualizerRef = useRef<DataSourceVirtualizer | undefined>();
|
let virtualizerRef = useRef<DataSourceVirtualizer | undefined>();
|
||||||
|
if (props.virtualizerRef) {
|
||||||
|
virtualizerRef = props.virtualizerRef as React.MutableRefObject<
|
||||||
|
DataSourceVirtualizer | undefined
|
||||||
|
>;
|
||||||
|
}
|
||||||
const [tableState, dispatch] = useReducer(
|
const [tableState, dispatch] = useReducer(
|
||||||
dataTableManagerReducer as DataTableReducer<T>,
|
dataTableManagerReducer as DataTableReducer<T>,
|
||||||
undefined,
|
undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user