Skip to content

feat(grid): multi-column sort and drag-to-reorder columns (#392) - #635

Merged
EVWorth merged 1 commit into
mainfrom
feat/results-sort-reorder
Sep 11, 2026
Merged

EVWorth merged 1 commit into
mainfrom
feat/results-sort-reorder

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Follows #626.

What

FR-3.1.2 and FR-3.1.5, neither of which existed. Sorting replaced its key on every click, so "department, then hire date" was inexpressible; column order was whatever the SELECT happened to list.

  • Shift+click adds a sort key. When more than one column sorts, each shows its position — two arrows with no order tell you the grid is multi-sorting but not which column wins.
  • First click sorts ascending on every column. TanStack infers descending-first for numeric ones, so clicking id and clicking name sorted opposite ways for no visible reason.
  • Dragging a header reorders, and the order is remembered.

The order is keyed on the result shape, not the query text: you narrow the same SELECT a dozen times in a session, and a text key would forget the layout on every WHERE change. Columns the result no longer has are dropped, new ones appended — so adding a column to a SELECT does not undo a drag. A footer control puts them back, and the store is capped so exploring a wide schema cannot eat the origin's storage quota.

Two bugs that fell out of doing it

  • The header was written twice — once for the virtualized path, once for the plain table — and the copies had drifted. Both now render one GridHeaderCell, so behaviour added to one cannot go missing above 5000 rows, which is where nobody looks. (Chips away at [P1] [arch] ResultsGrid.tsx is 916 LOC — god-component (split into header/footer/menu/save) #406.)
  • Pending insert rows are laid out cell by cell and iterated the query's own column order, which would put every value under the wrong header after a drag. They also read each cell's width from getFlatHeaders()[i + 1] — the neighbour's — because the row-number column is markup beside the table rather than one of its columns.

Verification

2281 unit + 305 browser tests pass. New coverage: 16 for the layout store, 12 for the header cell, 8 browser tests driving real TanStack (multi-sort ordering, priority badges, remembered order, insert-row alignment, reset). The insert-row test was mutation-checked against the old code.

Closes #392

🤖 Generated with Claude Code

FR-3.1.2 and FR-3.1.5, neither of which existed. Sorting replaced its key on
every click, so "department, then hire date" was inexpressible, and column
order was whatever the SELECT happened to list (#392).

- Shift+click adds a sort key. When more than one column is sorting, each
  shows its position — two arrows with no order tell you the grid is
  multi-sorting but not which column wins.
- First click now sorts ascending on every column. TanStack infers
  descending-first for numeric ones, so clicking `id` and clicking `name`
  sorted opposite ways for no reason the user could see.
- Dragging a header reorders, and the order is remembered.

The order is keyed on the *result shape*, not the query text: you narrow the
same SELECT a dozen times in a session, and a text key would forget the layout
on every WHERE change. Columns the result no longer has are dropped and new
ones appended, so adding a column to a SELECT does not undo a drag. A footer
control puts them back, because otherwise a stray drag is permanent, and the
store is capped so exploring a wide schema cannot eat the origin's quota.

Two things fell out of doing it:

- The header was written twice — once for the virtualized path, once for the
  plain table — and the copies had drifted. Both now render one
  `GridHeaderCell`, so behaviour added to one cannot go missing above 5000
  rows, which is where nobody looks.
- Pending insert rows are laid out cell by cell, and iterated the query's own
  column order, which would have put every value under the wrong header after
  a drag. They also read each cell's width from `getFlatHeaders()[i + 1]` —
  the neighbour's — because the row-number column is markup beside the table
  rather than one of its columns.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth merged commit 8b3458e into main Sep 11, 2026
12 checks passed
@EVWorth
EVWorth deleted the feat/results-sort-reorder branch September 11, 2026 05:18
@EVWorth EVWorth mentioned this pull request Sep 11, 2026
48 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P0] [doc-drift] FR-3.1.5 column reorder + FR-3.1.2 multi-sort — completely missing

1 participant