add context menu

This commit is contained in:
jeffvli
2026-02-09 12:51:22 -08:00
parent 9a2540f954
commit ab52693092
@@ -222,6 +222,22 @@ const TrackRow = memo(
[internalState, song], [internalState, song],
); );
const handleContextMenu = useCallback(
(event: React.MouseEvent<HTMLDivElement>) => {
if (isSongsLoading || !controls?.onMore) return;
event.preventDefault();
const index = internalState.findItemIndex(song.id);
controls.onMore({
event,
index,
internalState,
item: song,
itemType: LibraryItem.SONG,
});
},
[controls, internalState, isSongsLoading, song],
);
return ( return (
<div <div
className={clsx(styles.trackRow, { className={clsx(styles.trackRow, {
@@ -238,6 +254,7 @@ const TrackRow = memo(
[styles.trackRowWithHorizontalBorder]: rowIndex > 0, [styles.trackRowWithHorizontalBorder]: rowIndex > 0,
})} })}
onClick={handleRowClick} onClick={handleRowClick}
onContextMenu={handleContextMenu}
onMouseEnter={() => setIsRowHovered(true)} onMouseEnter={() => setIsRowHovered(true)}
onMouseLeave={() => setIsRowHovered(false)} onMouseLeave={() => setIsRowHovered(false)}
ref={dragRef ?? undefined} ref={dragRef ?? undefined}