Skip to content

Commit

Permalink
Merge pull request #1266 from joeworkman-forks/feature/dragdrop
Browse files Browse the repository at this point in the history
Do not preventDefault on item to support dragging
  • Loading branch information
Xon authored Feb 19, 2025
2 parents e36aa55 + 1de4ea8 commit ad31910
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/scripts/choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1886,18 +1886,24 @@ class Choices {
return;
}

let preventDefault = true;

const item = target.closest('[data-button],[data-item],[data-choice]');
if (item instanceof HTMLElement) {
if ('button' in item.dataset) {
this._handleButtonAction(item);
} else if ('item' in item.dataset) {
this._handleItemAction(item, event.shiftKey);
// don't prevent default to support dragging
preventDefault = false;
} else if ('choice' in item.dataset) {
this._handleChoiceAction(item);
}
}

event.preventDefault();
if (preventDefault) {
event.preventDefault();
}
}

/**
Expand Down

0 comments on commit ad31910

Please sign in to comment.