Skip to content

Commit 6792327

Browse files
authoredFeb 28, 2024··
fix: column getIsVisible works for parent group columns (#5380)
* fix: column getIsVisible works for parent group columns * update snapshot
1 parent c620b65 commit 6792327

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed
 

‎packages/react-table/__tests__/features/__snapshots__/Visibility.test.tsx.snap

-32
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,9 @@ exports[`useReactTable > can toggle column visibility > 0 - after toggling all o
44
{
55
"footers": [
66
[],
7-
[],
8-
[],
97
],
108
"headers": [
119
[],
12-
[],
13-
[],
1410
],
1511
"rows": [
1612
[],
@@ -304,20 +300,6 @@ exports[`useReactTable > can toggle column visibility > 3 - after toggling More
304300
"1",
305301
],
306302
],
307-
[
308-
[
309-
"",
310-
"1",
311-
],
312-
[
313-
"",
314-
"1",
315-
],
316-
[
317-
"",
318-
"1",
319-
],
320-
],
321303
[
322304
[
323305
"Name",
@@ -340,20 +322,6 @@ exports[`useReactTable > can toggle column visibility > 3 - after toggling More
340322
"1",
341323
],
342324
],
343-
[
344-
[
345-
"",
346-
"1",
347-
],
348-
[
349-
"",
350-
"1",
351-
],
352-
[
353-
"",
354-
"1",
355-
],
356-
],
357325
[
358326
[
359327
"firstName",

‎packages/table-core/src/features/Visibility.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,12 @@ export const Visibility: TableFeature = {
178178
}
179179
}
180180
column.getIsVisible = () => {
181-
return table.getState().columnVisibility?.[column.id] ?? true
181+
const childColumns = column.columns
182+
return (
183+
(childColumns.length
184+
? childColumns.some(c => c.getIsVisible())
185+
: table.getState().columnVisibility?.[column.id]) ?? true
186+
)
182187
}
183188

184189
column.getCanHide = () => {

0 commit comments

Comments
 (0)
Please sign in to comment.