Skip to content

Commit

Permalink
fix: column getIsVisible works for parent group columns (#5380)
Browse files Browse the repository at this point in the history
* fix: column getIsVisible works for parent group columns

* update snapshot
  • Loading branch information
KevinVandy authored Feb 28, 2024
1 parent c620b65 commit 6792327
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@ exports[`useReactTable > can toggle column visibility > 0 - after toggling all o
{
"footers": [
[],
[],
[],
],
"headers": [
[],
[],
[],
],
"rows": [
[],
Expand Down Expand Up @@ -304,20 +300,6 @@ exports[`useReactTable > can toggle column visibility > 3 - after toggling More
"1",
],
],
[
[
"",
"1",
],
[
"",
"1",
],
[
"",
"1",
],
],
[
[
"Name",
Expand All @@ -340,20 +322,6 @@ exports[`useReactTable > can toggle column visibility > 3 - after toggling More
"1",
],
],
[
[
"",
"1",
],
[
"",
"1",
],
[
"",
"1",
],
],
[
[
"firstName",
Expand Down
7 changes: 6 additions & 1 deletion packages/table-core/src/features/Visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ export const Visibility: TableFeature = {
}
}
column.getIsVisible = () => {
return table.getState().columnVisibility?.[column.id] ?? true
const childColumns = column.columns
return (
(childColumns.length
? childColumns.some(c => c.getIsVisible())
: table.getState().columnVisibility?.[column.id]) ?? true
)
}

column.getCanHide = () => {
Expand Down

0 comments on commit 6792327

Please sign in to comment.