From f8d1e084380daf46cbc273317235f93cfab57856 Mon Sep 17 00:00:00 2001 From: Kebechet Date: Sat, 25 Jul 2026 19:31:39 +0200 Subject: [PATCH] Enable multiDrag only when a selection class is configured --- BlazorSortableList.Lib/SortableList.razor.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/BlazorSortableList.Lib/SortableList.razor.js b/BlazorSortableList.Lib/SortableList.razor.js index eb13009..db2faf8 100644 --- a/BlazorSortableList.Lib/SortableList.razor.js +++ b/BlazorSortableList.Lib/SortableList.razor.js @@ -4,7 +4,8 @@ export function init(id, group, pull, put, sort, handle, filter, component, forc if (DEBUG_MODE) { console.log("Init for Id:", id, "swapThreshold:", swapThreshold); } - let multiDrag = (typeof cssForSelection !== 'undefined'); + // .NET marshals an unset string as null, never undefined, so a `typeof` check here would always pass. + let multiDrag = !!cssForSelection; let htmlElement = document.getElementById(id); if (!htmlElement) { @@ -65,7 +66,7 @@ export function init(id, group, pull, put, sort, handle, filter, component, forc handle: handle || undefined, multiDrag: multiDrag, - selectedClass: cssForSelection, + selectedClass: cssForSelection || undefined, multiDragKey: multiDragKey, avoidImplicitDeselect: avoidImplicitDeselect, swapThreshold: swapThreshold, //0.65, @@ -78,7 +79,8 @@ export function init(id, group, pull, put, sort, handle, filter, component, forc let oldIndex = event.oldDraggableIndex; let newIndex = event.newDraggableIndex; // in multi selection mode we have newIndicies only - let newIndicies = Array.from(event.newIndicies); + // Only the MultiDrag plugin adds these, so they are undefined when multiDrag is off. + let newIndicies = event.newIndicies ? Array.from(event.newIndicies) : []; if (newIndicies.length > 0) { newIndex = newIndicies[0].index; @@ -124,7 +126,8 @@ export function init(id, group, pull, put, sort, handle, filter, component, forc let newIndex = event.newDraggableIndex; // in multi selection mode we have newIndicies only - let newIndicies = Array.from(event.newIndicies); + // Only the MultiDrag plugin adds these, so they are undefined when multiDrag is off. + let newIndicies = event.newIndicies ? Array.from(event.newIndicies) : []; if (newIndicies.length > 0) { newIndex = newIndicies[0].index;