+
{
+ if (e.key !== `ArrowUp` && e.key !== `ArrowDown`) return;
+ e.preventDefault();
+ const allTracks = this.$provider.value?.tracks() ?? [];
+ if (allTracks.length === 0) return;
+ const current = this.$highlightedTrack.value;
+ const currentIdx = current
+ ? allTracks.findIndex((t) => t.id === current)
+ : -1;
+ const nextIdx = e.key === `ArrowUp`
+ ? Math.max(0, currentIdx - 1)
+ : Math.min(allTracks.length - 1, currentIdx + 1);
+ const next = allTracks[nextIdx];
+ this.#anchorTrackId = next.id;
+ this.$highlightedTracks.value = new Set([next.id]);
+ this.$highlightedTrack.value = next.id;
+ const panel = this.root().querySelector(`.sunken-panel`);
+ if (panel) {
+ const rowTop = nextIdx * ROW_HEIGHT;
+ const rowBottom = rowTop + ROW_HEIGHT;
+ if (rowTop < panel.scrollTop) {
+ panel.scrollTop = rowTop;
+ } else if (rowBottom > panel.scrollTop + panel.clientHeight) {
+ panel.scrollTop = rowBottom - panel.clientHeight;
+ }
+ }
+ }}"
+ >