Commit 26e0fd9
fix(playlist): allow removing the last track from a playlist (#14306)
## Summary
- **UI:** The trash icon in `CollectionTrackFieldArray` was disabled
whenever only one track remained. That guard fits the upload flow (which
reuses the same form) but blocked edits to existing playlists from ever
emptying out. `isUpload` now flows through from `EditCollectionForm`, so
the guard only applies during upload.
- **Backend:** Removing the final track via the kebab menu's "Remove
from playlist" appeared to succeed (optimistic update + toast) but the
track reappeared on reload. In `populate_playlist_record_metadata`, a
Python truthiness check on `playlist_metadata["playlist_contents"]`
treated the SDK's empty-array payload (`[]`) as if the field were
omitted and silently skipped the update. Switched to `is None` so an
explicit empty list is applied. Downstream `update_playlist_tracks`
already handles an empty `track_ids` correctly (marks all existing rows
removed).
## Repro
1. Visit a playlist with one track.
2. Track kebab → "Remove from playlist".
3. Confirmer succeeds, toast shows, track disappears from view.
4. Reload — track is still there.
Also: open the same playlist via "Edit Playlist" — the trash icon on the
only row was disabled.
## Test plan
- [ ] Edit-playlist form: remove the final track and save → playlist is
empty on reload.
- [ ] Track kebab → "Remove from playlist" on a one-track playlist →
playlist is empty on reload.
- [ ] Regression: removing one of several tracks still works in both
paths.
- [ ] Regression: upload flow still prevents bottoming out at zero
tracks.
- [ ] Backend regression: `playlist_contents: {"track_ids": []}` (legacy
dict form, used in existing tests) continues to update correctly.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>1 parent efa8352 commit 26e0fd9
3 files changed
Lines changed: 13 additions & 4 deletions
File tree
- packages
- discovery-provider/src/tasks/entity_manager/entities
- web/src/components
- edit-collection
- edit/fields
Lines changed: 4 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
680 | | - | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
681 | 684 | | |
682 | 685 | | |
683 | 686 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
Lines changed: 8 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
70 | 76 | | |
71 | 77 | | |
72 | 78 | | |
| |||
104 | 110 | | |
105 | 111 | | |
106 | 112 | | |
107 | | - | |
| 113 | + | |
108 | 114 | | |
109 | 115 | | |
110 | 116 | | |
| |||
0 commit comments