From cf4e408ff63d61fbefb82313eb6b6600eca67aff Mon Sep 17 00:00:00 2001 From: Alex Culliere Date: Tue, 2 Mar 2021 23:08:46 +0200 Subject: [PATCH] Fix cell sizes lookup in accordance with component lifecycle Signed-off-by: Alex Culliere --- .../item-object-list/item-list-layout.tsx | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/renderer/components/item-object-list/item-list-layout.tsx b/src/renderer/components/item-object-list/item-list-layout.tsx index 298c0b5d6f..42e890ab88 100644 --- a/src/renderer/components/item-object-list/item-list-layout.tsx +++ b/src/renderer/components/item-object-list/item-list-layout.tsx @@ -131,19 +131,19 @@ export class ItemListLayout extends React.Component { // create a registry to remember column sizes this.cellSizes = new Array(props.renderTableHeader.length); + + if (props.isResizable) { + this.cellSizes = this.persistentCellSizes; + } } async componentDidMount() { - const { isClusterScoped, isConfigurable, tableId, preloadStores, isResizable } = this.props; + const { isClusterScoped, isConfigurable, tableId, preloadStores } = this.props; if (isConfigurable && !tableId) { throw new Error("[ItemListLayout]: configurable list require props.tableId to be specified"); } - if (isResizable) { - this.cellSizes = this.persistentCellSizes; - } - if (preloadStores) { this.loadStores(); @@ -236,7 +236,6 @@ export class ItemListLayout extends React.Component { } persistCellSizes() { - console.log("Persisting sizes"); this.persistentCellSizes = this.cellSizes; } @@ -445,19 +444,15 @@ export class ItemListLayout extends React.Component { /> )} {renderTableHeader.map((cellProps, index) => { - const cellSize = this.cellSizes[index]; const _cellProps = isResizable ? { ...cellProps, _onResize: (width: number) => this.handleCellResize(index, width), _onResizeComplete: () => this.persistCellSizes(), + size: this.cellSizes[index], isResizable } : cellProps; - if (cellSize !== undefined) { - _cellProps.size = cellSize; - } - if (!this.isHiddenColumn(cellProps)) { return ; }