Skip to content

feat(ui): sort the track list by column heading - #6

Merged
kolebayev merged 2 commits into
devfrom
kolebayev/add-flat-view
Aug 21, 2026
Merged

kolebayev merged 2 commits into
devfrom
kolebayev/add-flat-view

Conversation

@kolebayev

Copy link
Copy Markdown
Owner

Summary

Column headings in the library are now the sort control: click one to sort by it, click it again to reverse. This replaces the Sort By radio group in the View menu, which offered four of the ten orders the list can be in and buried them two menus away from the columns they describe. The sort is remembered per grouping, so switching between flat and grouped no longer re-sorts the view you were leaving.

Changes

  • ui/lib/sort.ts (new) — sort keys per column, next-sort-on-click, arrow direction, and per-grouping prefs with tolerant localStorage parsing (seeds grouped views from the old single trackSort value).
  • ui/lib/types.ts — TrackSort becomes TrackSortState ({ key, dir }); TrackSortKey gains genre, trackNumber, year, time, bitrate, plays. SORT_LABELS removed.
  • ui/lib/grouping.ts — comparator table, one per key, each ascending with a title tie-break; descending is the comparator negated. Group headers follow the direction too.
  • ui/lib/columns.ts — new Added column; Album is now the flexible column instead of Title, derived rather than named so moving the slack is a one-line change.
  • ui/components/TrackList.tsx — ColumnSortButton fills each heading cell (resize handle still wins a press on the divider); flat rows carry a 24px cover; heading clips and mirrors the list's scrollLeft.
  • ui/components/LibraryHeaderRow.tsx — Sort By group removed from the View menu.
  • ui/index.css — html, body hide overflow and overscroll, so a wide track list can't slide the whole window sideways.
  • ui/lib/layout.ts (new) — SIDE_PANEL_WIDTH / SIDE_PANEL_MAX_WIDTH shared by Library's inspector and Convert's settings column, so the edge doesn't jump between tabs.
  • ui/components/StatsView.tsx — h-full instead of flex-1; the wrapper is a plain block, so the pane was sizing to content and the page scrolled behind it.

Test plan

  • npm test — 151 passing across 9 files, including 18 new in ui/lib/sort.test.ts and expanded grouping.test.ts (42) / columns.test.ts (18).
  • npx tsc --noEmit — clean.

Every heading is now a button: click sorts by that column, click again
reverses. This replaces the Sort By radio group in the View menu, which
offered four of the ten orders the list can be in and put them two menus
deep from the columns they describe.

The sort is stored per grouping rather than once for the list. Album
order is the only order that makes sense under an album header and a
poor one for a flat list, so sharing one value meant every switch
between grouped and flat silently re-sorted the view being left. Flat
view opens on artist A-Z, the grouped views on album order.

Around that:

- An Added column, so Recently Added has a heading that asks for it.
- Album absorbs the row's slack instead of Title. Title took the whole
  width of a wide window for a three-word string while the album beside
  it truncated.
- Flat rows carry their own cover art. The grouped views already show
  one per album header.
- The heading clips and mirrors the list's scrollLeft. A heading too
  wide for the window used to widen the document, and a sideways
  gesture slid the entire UI; html/body now hide overflow too.
- Library's inspector and Convert's settings column share one width
  constant, so the edge stops jumping when tabs are switched.
@kolebayev
kolebayev merged commit 6e6dfd9 into dev Aug 21, 2026
4 checks passed
@kolebayev
kolebayev deleted the kolebayev/add-flat-view branch August 21, 2026 14:29
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.

1 participant