feat(ui): add right-click context menu to track rows
Add context menu support (right-click) to the inline track rows in ArtistDetailView and LabelView popular tracks sections. Right-clicking a track opens the TrackMenu at the cursor position with all available actions. Also wires up TrackRow component with contextMenuPosition prop for the same functionality in reusable track rows.
This commit is contained in:
3 files changed
+22
No files matched your search
@@ -96,6 +96,7 @@
|
||||
}: Props = $props();
|
||||
|
||||
let isHovered = $state(false);
|
||||
let contextMenuPos = $state<{ x: number; y: number } | null>(null);
|
||||
let favoriteFromStore = $state(false);
|
||||
let isToggling = $state(false);
|
||||
|
||||
@@ -152,6 +153,11 @@
|
||||
onmouseenter={() => (isHovered = true)}
|
||||
onmouseleave={() => (isHovered = false)}
|
||||
onclick={isBlacklisted ? undefined : onPlay}
|
||||
oncontextmenu={(e) => {
|
||||
if (isBlacklisted) return;
|
||||
e.preventDefault();
|
||||
contextMenuPos = { x: e.clientX, y: e.clientY };
|
||||
}}
|
||||
role="button"
|
||||
tabindex={isBlacklisted ? -1 : 0}
|
||||
onkeydown={(e) => e.key === 'Enter' && !isBlacklisted && onPlay?.()}
|
||||
@@ -307,6 +313,8 @@
|
||||
isTrackDownloaded={menuActions?.isTrackDownloaded}
|
||||
onReDownload={menuActions?.onReDownload}
|
||||
onRemoveDownload={menuActions?.onRemoveDownload ?? onRemoveDownload}
|
||||
contextMenuPosition={contextMenuPos}
|
||||
onContextMenuClosed={() => { contextMenuPos = null; }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -151,6 +151,7 @@
|
||||
|
||||
let isRadioLoading = $state(false);
|
||||
let radioDropdownOpen = $state(false);
|
||||
let trackContextMenu = $state<{ trackId: number; x: number; y: number } | null>(null);
|
||||
let artistIsBlacklisted = $state(false);
|
||||
let isBlacklistLoading = $state(false);
|
||||
let showHideDropdown = $state(false);
|
||||
@@ -1678,6 +1679,10 @@
|
||||
data-track-id={track.id}
|
||||
onclick={() => handleTrackPlay(track, index)}
|
||||
onkeydown={(e) => e.key === 'Enter' && handleTrackPlay(track, index)}
|
||||
oncontextmenu={(e) => {
|
||||
e.preventDefault();
|
||||
trackContextMenu = { trackId: track.id, x: e.clientX, y: e.clientY };
|
||||
}}
|
||||
>
|
||||
<div class="track-number">{index + 1}</div>
|
||||
<div class="track-artwork">
|
||||
@@ -1775,6 +1780,8 @@
|
||||
onShareQobuz={onTrackShareQobuz ? () => onTrackShareQobuz(track.id) : undefined}
|
||||
onShareSonglink={onTrackShareSonglink ? () => onTrackShareSonglink(track) : undefined}
|
||||
onGoToAlbum={track.album?.id && onTrackGoToAlbum ? () => onTrackGoToAlbum(track.album!.id) : undefined}
|
||||
contextMenuPosition={trackContextMenu?.trackId === track.id ? { x: trackContextMenu.x, y: trackContextMenu.y } : null}
|
||||
onContextMenuClosed={() => { trackContextMenu = null; }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -108,6 +108,7 @@
|
||||
let loading = $state(true);
|
||||
let error = $state<string | null>(null);
|
||||
let pageData = $state<LabelPageData | null>(null);
|
||||
let trackContextMenu = $state<{ trackId: number; x: number; y: number } | null>(null);
|
||||
|
||||
// Parsed sections
|
||||
let topTracks = $state<Track[]>([]);
|
||||
@@ -817,6 +818,10 @@
|
||||
data-track-id={track.id}
|
||||
onclick={() => handleTrackPlay(track, index)}
|
||||
onkeydown={(e) => e.key === 'Enter' && handleTrackPlay(track, index)}
|
||||
oncontextmenu={(e) => {
|
||||
e.preventDefault();
|
||||
trackContextMenu = { trackId: track.id, x: e.clientX, y: e.clientY };
|
||||
}}
|
||||
>
|
||||
<div class="track-number">{index + 1}</div>
|
||||
<div class="track-artwork">
|
||||
@@ -910,6 +915,8 @@
|
||||
onAddFavorite={onTrackAddFavorite ? () => onTrackAddFavorite(track.id) : undefined}
|
||||
onAddToPlaylist={onTrackAddToPlaylist ? () => onTrackAddToPlaylist(track.id) : undefined}
|
||||
onGoToAlbum={track.album?.id && onTrackGoToAlbum ? () => onTrackGoToAlbum(track.album!.id) : undefined}
|
||||
contextMenuPosition={trackContextMenu?.trackId === track.id ? { x: trackContextMenu.x, y: trackContextMenu.y } : null}
|
||||
onContextMenuClosed={() => { trackContextMenu = null; }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user