Enter key now loads track

This commit is contained in:
patben8 committed 2026-09-25 13:43:40 +02:00
1 parent 88737f2b08
commit 0fd5d56a4e
2 files changed
+15 -2

No files matched your search

+2 -1
View File
@@ -347,7 +347,8 @@ Two independent apps that talk over HTTP:
devices. TanStack Table + **virtualized** grid; per-row play button,
configurable columns, header sorting, inline double-click editing, and
**Finder-style row selection** — click / Cmd-Ctrl+click / Shift+click over
the SORTED rows, ↑/↓ (Shift extends), Cmd/Ctrl+A, Esc; shortcuts stand down
the SORTED rows, ↑/↓ (Shift extends), Cmd/Ctrl+A, Esc, Enter (load + play
the highlighted row, winning over a focused button); shortcuts stand down
while an `aria-modal` dialog or `role="menu"` is open, so new dialogs need
`aria-modal="true"`. Right-click acts on the whole selection; single-track
items are hidden for a multi-selection. A view with a manual order passes
+13 -1
View File
@@ -451,7 +451,8 @@ export function TrackTable({
// Keyboard: ↑/↓ move the selection (Shift extends it), Cmd/Ctrl+A selects
// every visible row, Esc clears, Delete/Backspace removes (where the view
// allows it). Read through a ref so the listener is attached once.
// allows it), Enter loads the highlighted row into the deck and plays it.
// Read through a ref so the listener is attached once.
// ←/→, Space, C and digits belong to the deck (PrepStrip).
const keysRef = useRef<(e: KeyboardEvent) => void>(() => {})
keysRef.current = (e) => {
@@ -476,6 +477,17 @@ export function TrackTable({
selection.onChange(new Set())
return
}
if (e.key === 'Enter' && onPlay) {
// The highlighted row is the lead — the one last clicked or arrowed to,
// which in a multi-selection is the row the cursor is on.
const lead = indexOf(leadRef.current)
if (lead < 0 || !selection.selected.has(rows[lead].original.id)) return
// Wins over a focused button, as Space does for the deck: after clicking
// a playlist and arrowing down, Enter must not re-press that playlist.
e.preventDefault()
if (!e.repeat) onPlay(rows[lead].original)
return
}
if (e.key !== 'ArrowUp' && e.key !== 'ArrowDown') return
e.preventDefault()
const lead = indexOf(leadRef.current)