From 7fd5baf55982617212ec242c7f325b77f414570a Mon Sep 17 00:00:00 2001 From: Owen Mills Date: Sat, 23 Nov 2024 14:54:49 +0000 Subject: [PATCH] #1897: Prevent multi-select of non-draggable and filtered items --- plugins/MultiDrag/MultiDrag.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/MultiDrag/MultiDrag.js b/plugins/MultiDrag/MultiDrag.js index 2845f0d00..672a38aef 100644 --- a/plugins/MultiDrag/MultiDrag.js +++ b/plugins/MultiDrag/MultiDrag.js @@ -342,8 +342,19 @@ function MultiDragPlugin() { n = lastIndex + 1; } + const filter = options.filter; + for (; i < n; i++) { if (~multiDragElements.indexOf(children[i])) continue; + // Check if element is draggable + if (!closest(children[i], options.draggable, parentEl, false)) continue; + // Check if element is filtered + const filtered = filter && (typeof filter === 'function' ? + filter.call(sortable, evt, children[i], sortable) : + filter.split(',').some((criteria) => { + return closest(children[i], criteria.trim(), parentEl, false); + })); + if (filtered) continue; toggleClass(children[i], options.selectedClass, true); multiDragElements.push(children[i]);