Repository navigation
feat(grid): multi-column sort and drag-to-reorder columns (#392) - #635
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.
idand clickingnamesorted opposite ways for no visible reason.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
WHEREchange. 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
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.)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