Skip to content

Commit b3f155f

Browse files
Lukas742MarcusNotheis
authored andcommitted
fix(AnalyticalTable): fix table resize for hidden columns (#262)
1 parent 6cbb35d commit b3f155f

File tree

1 file changed

+9
-4
lines changed
  • packages/main/src/components/AnalyticalTable

1 file changed

+9
-4
lines changed

packages/main/src/components/AnalyticalTable/index.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,10 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
224224
);
225225

226226
const updateTableSizes = useCallback(() => {
227-
const visibleColumns = columns.filter(Boolean).filter(({ show }) => show ?? true);
228-
const columnsWithFixedWidth = columns
227+
const visibleColumns = columns.filter(Boolean).filter((item) => {
228+
return (item.isVisible ?? true) && !tableState.hiddenColumns.includes(item.accessor);
229+
});
230+
const columnsWithFixedWidth = visibleColumns
229231
.filter(({ width, minWidth }) => width ?? minWidth ?? false)
230232
.map(({ width, minWidth }) => width ?? minWidth);
231233
const fixedWidth = columnsWithFixedWidth.reduce((acc, val) => acc + val, 0);
@@ -236,7 +238,7 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
236238
} else {
237239
setColumnWidth(150);
238240
}
239-
}, [tableRef.current, columns]);
241+
}, [tableRef.current, columns, tableState.hiddenColumns]);
240242

241243
useEffect(() => {
242244
updateTableSizes();
@@ -349,7 +351,10 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
349351
{loading && busyIndicatorEnabled && data.length > 0 && <LoadingComponent />}
350352
{loading && data.length === 0 && (
351353
<TablePlaceholder
352-
columns={columns.filter((col) => col.show ?? true).length}
354+
columns={
355+
columns.filter((col) => (col.isVisible ?? true) && !tableState.hiddenColumns.includes(col.accessor))
356+
.length
357+
}
353358
rows={props.minRows}
354359
style={noDataStyles}
355360
rowHeight={internalRowHeight}

0 commit comments

Comments
 (0)