Skip to content

Reorder playlist songs and add new ones - #29

Merged
2SikNinja merged 6 commits into
masterfrom
edit-playlist-songs
Nov 17, 2026
Merged

2SikNinja merged 6 commits into
masterfrom
edit-playlist-songs

Conversation

@2SikNinja

@2SikNinja 2SikNinja commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Playlists can now be rearranged and have songs added.

Reordering:

  • Each song has a drag handle (always shown on phones, on hover or focus on desktop). Drag with a mouse or finger, or use the keyboard: focus the handle, press Space, move with the arrow keys, press Space to drop or Escape to cancel. Screen readers announce each step with the song's name.
  • Built on @dnd-kit (core, sortable, utilities), which handles pointer, touch and keyboard dragging.
  • The new order shows right away and is saved with PUT /api/playlists/:id/order. If saving fails, the old order comes back with an error message.

Adding songs:

  • An Add a song button under the list opens a search box. Each result has an Add button that puts the song at the end. The box stays open for adding more.
  • POST /api/playlists/:id/tracks adds the song, puts it back if it was removed earlier, or returns 409 if it's already playing.

Schema (migration 0009): a nullable playlist_tracks.sort_order column, and the position limit goes from 100 to 200, since positions stay as each song's fixed ID and added songs take the next one. Removing, putting back, the YouTube links and the on-page player all keep using position, and follow the new order automatically.

Migration 0009 is already applied to production and the dev branch.

Since #28 merged, songs added this way show "You added this" as their reason.

Browser tests (e2e/editing.spec.ts): dragging a song to the top with the mouse, moving one with the keyboard (waiting on each screen reader announcement), and adding a song from search, which lands at the end with "You added this". This branch also carries #32's fix to the test mock so the tests can run; merge #32 first and that commit drops out.

Testing: new service tests for adding, re-adding a removed song, refusing duplicates, a missing playlist, saving an order, and rejecting a stale order list. Checked in a local production build with mocked APIs: mouse dragging, keyboard moving with the announcements, and adding a song all work. Typecheck, lint and all 190 unit tests pass, and all 22 browser tests pass (two skipped on phones). The editing tests passed 4 times in a row.


Generated by Claude Code

@2SikNinja
2SikNinja merged commit 012d5bc into master Nov 17, 2026
4 checks passed
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