table icon indicating copy to clipboard operation
table copied to clipboard

Parent columns in groups are not respecting the isVisible value we're passing in

Open mattprice09 opened this issue 1 year ago • 3 comments

I believe this PR is the root cause.

We upgraded our @tanstack/react-table library from 8.9.3 to 8.20.5. Prior to this change, our header column parents were being hidden by us setting column visibility of the header column parents to false. We DO want the children columns to show, even when the parent columns are set to false. After making the upgrade to 8.20.5, the parent columns are showing, even though we are setting the column visibility to false.

Is there any way we can revert this PR, assuming it is the root cause here? To reiterate, we do not want parent column headers to show just because a child column is showing.

mattprice09 avatar Oct 03 '24 14:10 mattprice09

Hmmm, I think the fixed functionality is what actually makes sense here. You don't have to use this API if you want to check something else.

KevinVandy avatar Oct 03 '24 15:10 KevinVandy

Hmmm, I think the fixed functionality is what actually makes sense here. You don't have to use this API if you want to check something else.

@KevinVandy I agree that it makes sense to look at children column visibility for the fallback value, but IMO it would be ideal if the logic respected the assigned visibility state of the column. For example:

    column.getIsVisible = () => {
      return table.getState().columnVisibility?.[column.id] ?? true
      const childColumns = column.columns
      const columnHasVisibilitySpecified = !((table.getState().columnVisibility?.[column.id]) === undefined || table.getState().columnVisibility?.[column.id] === null));
      return (
         columnHasVisibilityAssigned
         ? table.getState().columnVisibility?.[column.id])
         : childColumns.length
           ? childColumns.some(c => c.getIsVisible()) : table.getState().columnVisibility?.[column.id])
           : true
      )

mattprice09 avatar Oct 03 '24 17:10 mattprice09

@KevinVandy Is this a solution you would be open to? If so, would you want me to create the PR for it?

mattprice09 avatar Oct 17 '24 15:10 mattprice09

@KevinVandy Is this a solution you would be open to? If so, would you want me to create the PR for it?

Only in the alpha. Want to limit breaking changes in main.

KevinVandy avatar Oct 31 '24 18:10 KevinVandy