Smart canonical-order column insertion in table picker#751
Merged
Conversation
…cker Previously the column picker always appended newly-toggled columns to the end of the order list. This adds canonical-rank-aware insertion: if the existing draft is in strictly-increasing canonical order (the order implicit in `_CATEGORIES`), splice the new column into the unique slot that keeps the sequence sorted. If the user has manually rearranged the draft out of canonical order, fall back to appending so we don't reshuffle their layout. Examples (against the default "p" group `[cover, name, child_count]`): toggle favorite → [cover, favorite, name, child_count] toggle imprint → [cover, imprint_name, name, child_count] toggle publisher → [cover, publisher_name, name, child_count] Covered by 16 new pure-function vitest cases. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
_CATEGORIES), splice into the unique sorted slot. If the user has manually rearranged the draft out of canonical order, fall back to appending so we don't reshuffle their layout.smartInsertIndexexported from the picker SFC and covered by 16 new vitest cases.Why
Always-append meant every newly-toggled column landed at the tail and required a drag to position. Most drafts (defaults plus light additions) are still in canonical order, so we can place the new column correctly without touching anything the user has intentionally arranged.
What changed
frontend/src/components/browser/table/browser-table-column-picker.vue: precompute_CANONICAL_RANKfrom_CATEGORIES, addsmartInsertIndex(draft, key), wiretoggleColumnto use it.frontend/tests/unit/browser-table-column-picker.test.js: new — covers canonical-order insertion, append-on-non-canonical fallback, edge cases (empty/single-element drafts), and orphan keys (rank+∞).Out of scope (intentionally)
Test plan
make lint-frontendcleanbun run test:ci— 5 files, 55 tests, all pass (16 new in this PR)🤖 Generated with Claude Code