diff --git a/packages/frontend/src/components/PaginatedSongList.tsx b/packages/frontend/src/components/PaginatedSongList.tsx index bd0da02..0c62a8b 100644 --- a/packages/frontend/src/components/PaginatedSongList.tsx +++ b/packages/frontend/src/components/PaginatedSongList.tsx @@ -171,6 +171,7 @@ export const PaginatedSongList: React.FC = memo(({ const timeoutRef = useRef(null); const [dragHoverIndex, setDragHoverIndex] = useState(null); const [endDropHover, setEndDropHover] = useState(false); + const [isReorderDragging, setIsReorderDragging] = useState(false); // Store current values in refs to avoid stale closures const hasMoreRef = useRef(hasMore); @@ -258,6 +259,9 @@ export const PaginatedSongList: React.FC = memo(({ const handleDragEnd = useCallback(() => { setIsDragging(false); + setIsReorderDragging(false); + setEndDropHover(false); + setDragHoverIndex(null); dragSelectionRef.current = null; }, []); @@ -280,7 +284,7 @@ export const PaginatedSongList: React.FC = memo(({ e.preventDefault(); setDragHoverIndex(index); }} - onRowDrop={async (e: React.DragEvent) => { + onRowDrop={async (e: React.DragEvent) => { if (!onReorder || !currentPlaylist || selectedSongs.size > 0) return; e.preventDefault(); const fromId = e.dataTransfer.getData('text/song-id'); @@ -303,7 +307,8 @@ export const PaginatedSongList: React.FC = memo(({ console.debug('[Reorder] move request', { playlist: currentPlaylist, fromId, toId }); await api.moveTrackInPlaylist(currentPlaylist, fromId, toId); await onReorder(songs.map(s => s.id)); // trigger refresh via parent - setDragHoverIndex(null); + setDragHoverIndex(null); + setIsReorderDragging(false); }} onRowDragStartCapture={(e: React.DragEvent) => { // Provide a simple id for intra-list reorder @@ -313,6 +318,7 @@ export const PaginatedSongList: React.FC = memo(({ // Explicitly set effect to move for better UX try { e.dataTransfer.effectAllowed = 'move'; } catch {} try { e.dataTransfer.dropEffect = 'move'; } catch {} + setIsReorderDragging(true); }} /> )); @@ -503,7 +509,7 @@ export const PaginatedSongList: React.FC = memo(({ {/* Drop zone to move item to end of playlist */} - {onReorder && currentPlaylist && selectedSongs.size === 0 && ( + {onReorder && currentPlaylist && selectedSongs.size === 0 && isReorderDragging && ( { e.preventDefault(); @@ -521,7 +527,9 @@ export const PaginatedSongList: React.FC = memo(({ await api.moveTrackInPlaylist(currentPlaylist, fromId); await onReorder(songs.map(s => s.id)); setEndDropHover(false); + setIsReorderDragging(false); }} + onDragEnd={handleDragEnd} position="relative" height="28px" mt={1}