Skip to content

Commit af6fb07

Browse files
committed
frontend: Hide row actions with hidden columns
Signed-off-by: Evangelos Skopelitis <[email protected]>
1 parent 950f656 commit af6fb07

File tree

1 file changed

+15
-0
lines changed
  • frontend/src/components/common/Table

1 file changed

+15
-0
lines changed

frontend/src/components/common/Table/Table.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,21 @@ export default function Table<RowItem extends Record<string, any>>({
320320
},
321321
});
322322

323+
// Hide actions column when others are hidden
324+
useEffect(() => {
325+
const visibility = table.getState().columnVisibility || {};
326+
327+
const shouldHideActions = tableColumns
328+
.filter(col => (col.id ?? '') !== 'actions')
329+
.every(col => visibility[col.id ?? ''] === false);
330+
331+
if (shouldHideActions && visibility['actions'] !== false) {
332+
table.setColumnVisibility(prev => ({ ...prev, actions: false }));
333+
} else if (!shouldHideActions && visibility['actions'] === false) {
334+
table.setColumnVisibility(prev => ({ ...prev, actions: true }));
335+
}
336+
}, [table.getState().columnVisibility, tableColumns, table]);
337+
323338
const gridTemplateColumns = useMemo(() => {
324339
let preGridTemplateColumns = tableProps.columns
325340
.filter((it, i) => {

0 commit comments

Comments
 (0)