Skip to main content

toggle_sorting_state_tanstack

Function toggle_sorting_state_tanstack 

Source
pub fn toggle_sorting_state_tanstack(
    sorting: &mut Vec<SortSpec>,
    column: &SortToggleColumn,
    options: TableOptions,
    multi: bool,
    auto_sort_dir_desc: bool,
)
Expand description

TanStack-aligned sorting state transition for column.toggleSorting(undefined, multi).

This implements the upstream action logic (add/toggle/remove/replace) including:

  • sortDescFirst (table + column)
  • enableSortingRemoval (note: TanStack’s toggleSorting does not pass the multi flag to getNextSortingOrder, so enableMultiRemove does not affect the direct toggle behavior)
  • enableMultiSort / maxMultiSortColCount

Notes:

  • This models the behavior of calling column.toggleSorting directly. It does not include UI gating like getCanSort() (which TanStack applies in getToggleSortingHandler).
  • This currently does not implement TanStack’s getAutoSortDir() inference (string => asc, else desc) when sortDescFirst is unset. Until we add a stable “sort value extractor” surface, the fallback first direction is asc.