Skip to content

Commit

Permalink
*fix Table columns matching (hidden columns are not omitted)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sodik committed Nov 29, 2024
1 parent 80da390 commit 792f10a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/ui/src/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ export const Table = <D extends object>({
previousPage,
setPageSize,
// Get the state from the instance
state: { pageIndex, pageSize, sortBy, columnResizing, selectedRowIds },
state: { pageIndex, pageSize, sortBy, columnResizing, selectedRowIds, hiddenColumns },
setGlobalFilter,
setColumnOrder,
} = tableInstance
Expand Down Expand Up @@ -528,6 +528,13 @@ export const Table = <D extends object>({
const cellIndexOffset = pageSize * pageIndex + headerIndex
// Total row count.
const rowCount = data.length + headerIndex + (hasFooter ? 1 : 0)
const contentColumns = useMemo(() => {
if (!hiddenColumns || hiddenColumns.length === 0) {
return columns
}

return columns.filter((col) => hiddenColumns?.includes((col.id || col.Header) as string))
}, [columns, hiddenColumns])

const content = (
<>
Expand Down Expand Up @@ -591,7 +598,7 @@ export const Table = <D extends object>({
page={page}
onCopy={onCopy}
getHref={getHref}
columns={columns}
columns={contentColumns}
rootRef={setContextMenuAnchorEl}
{...columnsSelectionProps}
onRowClick={onRowClick}
Expand Down

0 comments on commit 792f10a

Please sign in to comment.