reorderColumns
reorderColumns<
TFieldSlug>(props):ColumnEntry<TFieldSlug>[]
Defined in: packages/react/src/ui/data-table/DataTableColumnsMenu.tsx:106
Applies a drag/keyboard reorder — from/to are indices WITHIN the
READABLE subsequence only (readableFields, the rows this menu
actually renders and @hello-pangea/dnd reports indices against) —
back onto the FULL column list (Decision 48), which may additionally
include unreadable fields this viewer never sees a row for. An
unreadable field keeps its original absolute position (AND its own
entry, untouched) — only the readable fields shift among themselves, in
their new relative order, each carrying its own width/pinned/
hidden overrides along with it (a reorder never touches those).
Exported for direct unit testing — the fiddly index-translation logic
shouldn’t only be exercised through a simulated drag gesture, which
this repo’s ui/dnd tests don’t attempt (see DragHandle.test.tsx:
structural assertions only, no simulated @hello-pangea/dnd gesture).
Type Parameters
Section titled “Type Parameters”TFieldSlug
Section titled “TFieldSlug”TFieldSlug extends string = string
Parameters
Section titled “Parameters”Input props.
columns
Section titled “columns”ColumnEntry<TFieldSlug>[]
The full column list before this reorder.
number
The dragged row’s index within readableFields.
readableFields
Section titled “readableFields”TFieldSlug[]
The readable subsequence, in ITS current
(pre-reorder) order — i.e. columns filtered down to what this menu
rendered a row for.
number
Its drop index within readableFields.
Returns
Section titled “Returns”ColumnEntry<TFieldSlug>[]
The new full column list, or props.columns unchanged when
from === to or either index is out of range.