Skip to content

Commit 624e84f

Browse files
vberschMarcusNotheis
authored andcommitted
fix(AnalyticalTable): re-enable setting isVisible on column to show/hide columns (#278)
1 parent eedb9f8 commit 624e84f

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,20 @@ const AnalyticalTable: FC<TableProps> = forwardRef((props: TableProps, ref: Ref<
270270
dispatch({ type: 'SET_SELECTED_ROWS', selectedIds: selectedRowIds });
271271
}, [selectedRowIds, dispatch]);
272272

273+
useEffect(() => {
274+
dispatch({
275+
type: 'SET_HIDDEN_COLUMNS',
276+
hiddenColumns: columns
277+
.filter((col) => {
278+
if (col.hasOwnProperty('isVisible')) {
279+
return !col.isVisible;
280+
}
281+
return false;
282+
})
283+
.map((col) => col.accessor)
284+
});
285+
}, [columns]);
286+
273287
const tableContainerClasses = StyleClassHelper.of(classes.tableContainer);
274288

275289
if (theme.contentDensity === ContentDensity.Compact) {

packages/main/src/components/AnalyticalTable/tableReducer/stateReducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ export const stateReducer = (newState, action, prevState) => {
55
return { ...prevState, groupBy: payload };
66
case 'SET_SELECTED_ROWS':
77
return { ...prevState, selectedRowIds: action.selectedIds };
8+
case 'SET_HIDDEN_COLUMNS':
9+
return { ...prevState, hiddenColumns: action.hiddenColumns };
810
default:
911
return newState;
1012
}

0 commit comments

Comments
 (0)