Skip to content

Commit

Permalink
Merge pull request #2084 from Agnaev/master
Browse files Browse the repository at this point in the history
avoid implicit deselect on outside click
  • Loading branch information
owen-m1 authored Oct 3, 2021
2 parents 21f7ede + 796bb3f commit b8940a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions plugins/MultiDrag/MultiDrag.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ function MultiDragPlugin() {
}
}

if (sortable.options.supportPointer) {
on(document, 'pointerup', this._deselectMultiDrag);
} else {
on(document, 'mouseup', this._deselectMultiDrag);
on(document, 'touchend', this._deselectMultiDrag);
if (!sortable.options.avoidImplicitDeselect) {
if (sortable.options.supportPointer) {
on(document, 'pointerup', this._deselectMultiDrag);
} else {
on(document, 'mouseup', this._deselectMultiDrag);
on(document, 'touchend', this._deselectMultiDrag);
}
}

on(document, 'keydown', this._checkKeyDown);
Expand All @@ -48,6 +50,7 @@ function MultiDragPlugin() {
this.defaults = {
selectedClass: 'sortable-selected',
multiDragKey: null,
avoidImplicitDeselect: false,
setData(dataTransfer, dragEl) {
let data = '';
if (multiDragElements.length && multiDragSortable === sortable) {
Expand Down
3 changes: 2 additions & 1 deletion plugins/MultiDrag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ new Sortable(el, {
multiDrag: true, // Enable the plugin
selectedClass: "sortable-selected", // Class name for selected item
multiDragKey: null, // Key that must be down for items to be selected

avoidImplicitDeselect: false, // true - if you don't want to deselect items on outside click

// Called when an item is selected
onSelect: function(/**Event*/evt) {
evt.item // The selected item
Expand Down

0 comments on commit b8940a9

Please sign in to comment.