Skip to content

Commit

Permalink
fix: preserve header pinning order
Browse files Browse the repository at this point in the history
Fixes #3915
  • Loading branch information
tannerlinsley committed May 15, 2022
1 parent 4c57a8a commit ade3cc7
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions packages/table-core/src/features/Headers.ts
Expand Up @@ -121,15 +121,20 @@ export const Headers = {
instance.getState().columnPinning.right,
],
(allColumns, leafColumns, left, right) => {
const leftColumns = leafColumns.filter(column =>
left?.includes(column.id)
)
const rightColumns = leafColumns.filter(column =>
right?.includes(column.id)
)
const leftColumns =
left
?.map(columnId => leafColumns.find(d => d.id === columnId)!)
.filter(Boolean) ?? []

const rightColumns =
right
?.map(columnId => leafColumns.find(d => d.id === columnId)!)
.filter(Boolean) ?? []

const centerColumns = leafColumns.filter(
column => !left?.includes(column.id) && !right?.includes(column.id)
)

const headerGroups = buildHeaderGroups(
allColumns,
[...leftColumns, ...centerColumns, ...rightColumns],
Expand Down

1 comment on commit ade3cc7

@vercel
Copy link

@vercel vercel bot commented on ade3cc7 May 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

react-table – ./

react-table-tanstack.vercel.app
react-table-v8.tanstack.com
react-table-git-alpha-tanstack.vercel.app

Please sign in to comment.