Skip to content

Commit

Permalink
fix group visibility state not changing for sho / hide all buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
ThisIsHG committed Feb 28, 2024
1 parent c31ae22 commit 84b9f88
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -27,7 +27,6 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
}: MRT_ShowHideColumnsMenuProps<TData>) => {
const {
getAllColumns,
getAllLeafColumns,
getCenterLeafColumns,
getIsAllColumnsVisible,
getIsSomeColumnsPinned,
Expand All @@ -45,10 +44,20 @@ export const MRT_ShowHideColumnsMenu = <TData extends MRT_RowData>({
} = table;
const { columnOrder, columnPinning, density } = getState();

const handleToggleAllColumns = (value?: boolean) => {
getAllLeafColumns()
const changeColumnVisibility = (
columns: MRT_Column<TData>[],
value?: boolean,
) => {
columns
.filter((col) => col.columnDef.enableHiding !== false)
.forEach((col) => col.toggleVisibility(value));
.forEach((col) => {
col.toggleVisibility(value);
if (col.columns) changeColumnVisibility(col.columns, value);
});
};

const handleToggleAllColumns = (value?: boolean) => {
changeColumnVisibility(getAllColumns(), value);
};

const allColumns = useMemo(() => {
Expand Down

0 comments on commit 84b9f88

Please sign in to comment.