From 4dae4037363a226cc778f8ea56502a4f263fab91 Mon Sep 17 00:00:00 2001 From: Dmitry Kurmanov Date: Mon, 11 Mar 2024 14:59:38 +0400 Subject: [PATCH] work for the https://github.com/surveyjs/survey-library/issues/7935 (#7941) --- src/dragdrop/ranking-select-to-rank.ts | 15 +++++---------- tests/dragdrophelpertests.ts | 6 ++++++ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/dragdrop/ranking-select-to-rank.ts b/src/dragdrop/ranking-select-to-rank.ts index 28ea46a155..0c2cf41b19 100644 --- a/src/dragdrop/ranking-select-to-rank.ts +++ b/src/dragdrop/ranking-select-to-rank.ts @@ -10,16 +10,11 @@ export class DragDropRankingSelectToRank extends DragDropRankingChoices { return dragOverNode; } - if ( - this.parentElement.rankingChoices.length === 0 || - this.parentElement.unRankingChoices.length === 0 - ) { - let toContainer: HTMLElement = dragOverNode.closest("[data-ranking='to-container']"); - let fromContainer: HTMLElement = dragOverNode.closest("[data-ranking='from-container']"); - - if (!!toContainer) return toContainer; - if (!!fromContainer) return fromContainer; - } + let toContainer: HTMLElement = dragOverNode.closest("[data-ranking='to-container']"); + let fromContainer: HTMLElement = dragOverNode.closest("[data-ranking='from-container']"); + + if (this.parentElement.unRankingChoices.length === 0 && fromContainer) return fromContainer; + if (this.parentElement.rankingChoices.length === 0 && toContainer) return toContainer; return super.findDropTargetNodeByDragOverNode(dragOverNode); } diff --git a/tests/dragdrophelpertests.ts b/tests/dragdrophelpertests.ts index 73215744d2..88686d2909 100644 --- a/tests/dragdrophelpertests.ts +++ b/tests/dragdrophelpertests.ts @@ -313,6 +313,12 @@ QUnit.test("DragDropRankingSelectToRank getIndixies", function (assert) { assert.equal(toIndex, 2); toIndex = dndModel.getIndixies(questionModel, questionModel.rankingChoices, questionModel.rankingChoices).toIndex; assert.equal(toIndex, 1); + + questionModel.value = ["11", "22", "33"]; + dndModel.draggedElement = questionModel.rankingChoices[0]; + dndModel.dropTarget = questionModel.rankingChoices[1]; + toIndex = dndModel.getIndixies(questionModel, questionModel.rankingChoices, questionModel.rankingChoices).toIndex; + assert.equal(toIndex, 1); }); // EO selectToRankEnabled