fix(reorder): enable landing indicator and drop handling for multi-drag; start reorder on multi-select; relax guards to allow multi block moves
This commit is contained in:
parent
d13fe81ade
commit
0073f8146d
@ -251,6 +251,7 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
|
||||
const ids = selectedSongs.size > 0 ? Array.from(selectedSongs) : songIdsFallback;
|
||||
dragSelectionRef.current = ids;
|
||||
setIsDragging(true);
|
||||
setIsReorderDragging(true);
|
||||
const payload = { type: 'songs', songIds: ids, count: ids.length };
|
||||
e.dataTransfer.setData('application/json', JSON.stringify(payload));
|
||||
e.dataTransfer.setData('text/plain', JSON.stringify(payload));
|
||||
@ -280,12 +281,12 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
|
||||
onDragStart={handleDragStart}
|
||||
// Simple playlist reordering within same list by dragging rows
|
||||
onRowDragOver={(e: React.DragEvent) => {
|
||||
if (!onReorder || !currentPlaylist || selectedSongs.size > 0) return;
|
||||
if (!onReorder || !currentPlaylist) return;
|
||||
e.preventDefault();
|
||||
setDragHoverIndex(index);
|
||||
}}
|
||||
onRowDrop={async (e: React.DragEvent) => {
|
||||
if (!onReorder || !currentPlaylist || selectedSongs.size > 0) return;
|
||||
if (!onReorder || !currentPlaylist) return;
|
||||
e.preventDefault();
|
||||
const fromId = e.dataTransfer.getData('text/song-id');
|
||||
const multiJson = e.dataTransfer.getData('application/json');
|
||||
@ -301,8 +302,8 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
|
||||
if (!fromId && !multiIds) return;
|
||||
const fromIndex = fromId ? songs.findIndex(s => s.id === fromId) : -1;
|
||||
const toIndex = index;
|
||||
if (fromIndex < 0 || toIndex < 0) return;
|
||||
if (fromIndex === toIndex) return;
|
||||
if (toIndex < 0) return;
|
||||
if (fromId && fromIndex >= 0 && fromIndex === toIndex) return;
|
||||
const toId = songs[index].id;
|
||||
// If multiple, move block; else move single
|
||||
if (multiIds && multiIds.length > 0) {
|
||||
@ -316,7 +317,7 @@ export const PaginatedSongList: React.FC<PaginatedSongListProps> = memo(({
|
||||
}}
|
||||
onRowDragStartCapture={(e: React.DragEvent) => {
|
||||
// Provide a simple id for intra-list reorder
|
||||
if (!currentPlaylist || selectedSongs.size > 0) return;
|
||||
if (!currentPlaylist) return;
|
||||
e.dataTransfer.setData('text/song-id', song.id);
|
||||
// Explicitly set effect to move for better UX
|
||||
try { e.dataTransfer.effectAllowed = 'move'; } catch {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user