mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix cell sizes lookup in accordance with component lifecycle
Signed-off-by: Alex Culliere <alozhkin@mirantis.com>
This commit is contained in:
parent
4eafc6d81b
commit
cf4e408ff6
@ -131,19 +131,19 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
|||||||
|
|
||||||
// create a registry to remember column sizes
|
// create a registry to remember column sizes
|
||||||
this.cellSizes = new Array<number>(props.renderTableHeader.length);
|
this.cellSizes = new Array<number>(props.renderTableHeader.length);
|
||||||
|
|
||||||
|
if (props.isResizable) {
|
||||||
|
this.cellSizes = this.persistentCellSizes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
const { isClusterScoped, isConfigurable, tableId, preloadStores, isResizable } = this.props;
|
const { isClusterScoped, isConfigurable, tableId, preloadStores } = this.props;
|
||||||
|
|
||||||
if (isConfigurable && !tableId) {
|
if (isConfigurable && !tableId) {
|
||||||
throw new Error("[ItemListLayout]: configurable list require props.tableId to be specified");
|
throw new Error("[ItemListLayout]: configurable list require props.tableId to be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isResizable) {
|
|
||||||
this.cellSizes = this.persistentCellSizes;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (preloadStores) {
|
if (preloadStores) {
|
||||||
this.loadStores();
|
this.loadStores();
|
||||||
|
|
||||||
@ -236,7 +236,6 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
persistCellSizes() {
|
persistCellSizes() {
|
||||||
console.log("Persisting sizes");
|
|
||||||
this.persistentCellSizes = this.cellSizes;
|
this.persistentCellSizes = this.cellSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -445,19 +444,15 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{renderTableHeader.map((cellProps, index) => {
|
{renderTableHeader.map((cellProps, index) => {
|
||||||
const cellSize = this.cellSizes[index];
|
|
||||||
const _cellProps = isResizable ?
|
const _cellProps = isResizable ?
|
||||||
{
|
{
|
||||||
...cellProps,
|
...cellProps,
|
||||||
_onResize: (width: number) => this.handleCellResize(index, width),
|
_onResize: (width: number) => this.handleCellResize(index, width),
|
||||||
_onResizeComplete: () => this.persistCellSizes(),
|
_onResizeComplete: () => this.persistCellSizes(),
|
||||||
|
size: this.cellSizes[index],
|
||||||
isResizable
|
isResizable
|
||||||
} : cellProps;
|
} : cellProps;
|
||||||
|
|
||||||
if (cellSize !== undefined) {
|
|
||||||
_cellProps.size = cellSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.isHiddenColumn(cellProps)) {
|
if (!this.isHiddenColumn(cellProps)) {
|
||||||
return <TableCell key={cellProps.id ?? index} {..._cellProps} />;
|
return <TableCell key={cellProps.id ?? index} {..._cellProps} />;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user