Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions packages/core/src/components/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,20 @@ export class DataTable extends React.Component<DataTableProps & WithStylesProps,
});
} else if (dynamicRowHeight && (filteredDataChanged || dimensionsChanged || sortChanged)) {
// We need to make sure the cache is cleared before React tries to re-render.
if (this.timeoutId) window.clearTimeout(this.timeoutId);
this.timeoutId = window.setTimeout(() => {
this.cache.clearAll();
this.forceUpdate();
});
if (!this.timeoutId) {
this.timeoutId = window.setTimeout(() => {
this.cache.clearAll();
this.forceUpdate();
this.timeoutId = 0;
});
}
}
}

componentWillUnmount() {
if (this.timeoutId) window.clearTimeout(this.timeoutId);
}

private getTableHeight = (expandedDataList: ExpandedRow[]): number => {
const { height, rowHeight, showAllRows, dynamicRowHeight } = this.props;
// @ts-ignore _rowHeightCache is missing from DataTable types
Expand Down Expand Up @@ -222,11 +228,13 @@ export class DataTable extends React.Component<DataTableProps & WithStylesProps,

if (dynamicRowHeight) {
// We need to make sure the cache is cleared before React tries to re-render.
if (this.timeoutId) window.clearTimeout(this.timeoutId);
this.timeoutId = window.setTimeout(() => {
this.cache.clearAll();
this.forceUpdate();
});
if (!this.timeoutId) {
this.timeoutId = window.setTimeout(() => {
this.cache.clearAll();
this.forceUpdate();
this.timeoutId = 0;
});
}
}
};

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/DataTable/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const HEIGHT_TO_PX: HeightMap = {
small: 48,
regular: 56,
large: 64,
xLarge: 80,
xlarge: 80,
jumbo: 108,
};

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/DataTable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { DataTable } from './DataTable';

export type DataTableRef = (instance: DataTable) => void;
export type TableRef = React.RefObject<Table>;
export type RowHeightOptions = 'micro' | 'small' | 'regular' | 'large' | 'xLarge' | 'jumbo';
export type RowHeightOptions = 'micro' | 'small' | 'regular' | 'large' | 'xlarge' | 'jumbo';
export type HeightOptions = RowHeightOptions | undefined;
export type ColumnLabelCase = 'sentence' | 'title' | 'uppercase' | '';

Expand Down