Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov committed Aug 5, 2024
1 parent 658040d commit 17570bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/dragdrop/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export abstract class DragDropCore<T> implements IDragDropEngine {

public onDragStart: EventBase<DragDropCore<T>> = new EventBase();
public onDragEnd: EventBase<DragDropCore<T>> = new EventBase();
public onDragClear: EventBase<DragDropCore<T>> = new EventBase();
public onBeforeDrop = this.onDragStart;
public onAfterDrop = this.onDragEnd;

Expand Down Expand Up @@ -243,5 +244,6 @@ export abstract class DragDropCore<T> implements IDragDropEngine {
this.draggedElement = null;
this.isBottom = null;
this.parentElement = null;
this.onDragClear.fire(this, {});
}
}
9 changes: 8 additions & 1 deletion tests/dragdrophelpertests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ QUnit.test("dropTargetDataAttributeName for choices", function (assert) {
);
});

QUnit.test("choices: onDragStart and onDragEnd events", function (assert) {
QUnit.test("choices: onDragStart, onDragEnd, onDragClear events", function (assert) {
const survey = new SurveyModel({
elements: [
{
Expand All @@ -131,6 +131,7 @@ QUnit.test("choices: onDragStart and onDragEnd events", function (assert) {
);
let beforeCount = 0;
let afterCount = 0;
let clearCount = 0;
let draggedElementParent;

const ddHelper: any = new DragDropChoices(survey);
Expand All @@ -141,6 +142,10 @@ QUnit.test("choices: onDragStart and onDragEnd events", function (assert) {
afterCount++;
draggedElementParent = options.draggedElement;
});
ddHelper.onDragClear.add((sender, options) => {
clearCount++;
});

ddHelper.parentElement = question;
ddHelper.draggedElement = question.choices[2];

Expand All @@ -154,6 +159,8 @@ QUnit.test("choices: onDragStart and onDragEnd events", function (assert) {
ddHelper["drop"]();
assert.equal(afterCount, 1);
assert.equal(draggedElementParent.name, "q");
ddHelper["clear"]();
assert.equal(clearCount, 1);
});

QUnit.test("DragDropRankingChoices shortcutClass getter", function (assert) {
Expand Down

0 comments on commit 17570bb

Please sign in to comment.