Fix: allow reordering pinned columns #1110
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I noticed that while having
enableColumnOrdering
,enableColumnPinning
, andenableColumnDragging
enabled the reorder action didn't impact the order of the pinned columns from either the drag handle or from the columns menu.Example:
column-pin-reordering.mov
I had two approaches in mind to fix this
MRT_TableHeadCellGrabHandle
andMRT_ShowHideColumnsMenuItems
to reorder the pins where appropriate (columns are able to pin and are pinned)I thought the second approach might be more appropriate to ensure this behavior works across other potential reorder actions, and so that the aforementioned components can remain simpler and just continue to call
setColumnOrder
.However I wasn't able to find the best place in TanStack Table's source code to address this, so I opted to make the change seen in this PR. I'm very open to figuring out the change in TanStack if you agree that's a better place to fix it, and especially if you have some pointers on where I might look to investigate this behavior there.
An example, with this change applied:
column-pin-reordering-fix.mov
I opted to not run this reordering when an unpinned column is dragged into the pinned column area, maintaining that action as just a form of calling
pin
on the column.