Skip to content

Commit

Permalink
work for the #7884 (#7896)
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kurmanov authored Feb 22, 2024
1 parent 8e39f30 commit 7c6b930
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/dragdrop/ranking-select-to-rank.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ export class DragDropRankingSelectToRank extends DragDropRankingChoices {
let fromIndex = fromChoicesArray.indexOf(this.draggedElement);
let toIndex = toChoicesArray.indexOf(this.dropTarget);

if (toIndex === -1) toIndex = model.value.length;
if (toIndex === -1) {
const length = model.value.length;
toIndex = fromChoicesArray === toChoicesArray ? length - 1 : length;
}

return { fromIndex, toIndex };
}
Expand Down
4 changes: 3 additions & 1 deletion tests/dragdrophelpertests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,10 @@ QUnit.test("DragDropRankingSelectToRank getIndixies", function (assert) {
const dndModel = new DragDropRankingSelectToRank();
const questionModel = createRankingQuestionModel(withDefaultValue);

let { toIndex } = dndModel.getIndixies(questionModel, questionModel.rankingChoices, questionModel.unRankingChoices);
let toIndex = dndModel.getIndixies(questionModel, questionModel.rankingChoices, questionModel.unRankingChoices).toIndex;
assert.equal(toIndex, 2);
toIndex = dndModel.getIndixies(questionModel, questionModel.rankingChoices, questionModel.rankingChoices).toIndex;
assert.equal(toIndex, 1);
});
// EO selectToRankEnabled

Expand Down

0 comments on commit 7c6b930

Please sign in to comment.