diff --git a/js/ui/sortable.js b/js/ui/sortable.js index 3071217411e2..96414f4e281f 100644 --- a/js/ui/sortable.js +++ b/js/ui/sortable.js @@ -254,9 +254,10 @@ const Sortable = Draggable.inherit({ }, _isValidPoint: function(visibleIndex, draggableVisibleIndex, dropInsideItem) { + const allowDropInsideItem = this.option('allowDropInsideItem'); const allowReordering = dropInsideItem || this._allowReordering(); - if(!allowReordering && visibleIndex !== 0) { + if(!allowReordering && (visibleIndex !== 0 || !allowDropInsideItem)) { return false; } diff --git a/testing/tests/DevExpress.ui.widgets/listParts/editingUITests.js b/testing/tests/DevExpress.ui.widgets/listParts/editingUITests.js index 3e584f7db4af..825bf1cef660 100644 --- a/testing/tests/DevExpress.ui.widgets/listParts/editingUITests.js +++ b/testing/tests/DevExpress.ui.widgets/listParts/editingUITests.js @@ -2926,3 +2926,26 @@ QUnit.test('items should reset positions after dragend', function(assert) { }); }); +// T856292 +QUnit.test('Drag and drop item to the top of the list should not work when allowReordering is false', function(assert) { + const $list = $('#list').dxList({ + items: ['0', '1', '2'], + itemDragging: { + allowReordering: false, + group: 'shared' + } + }); + + let $items = $list.find(toSelector(LIST_ITEM_CLASS)); + const $item3 = $items.eq(2); + const pointer = reorderingPointerMock($item3, this.clock); + + pointer.dragStart(0.5).drag(-1).drag(-1.5).dragEnd(); + + $items = $list.find(toSelector(LIST_ITEM_CLASS)); + $.each($items, (index, item) => { + const $item = $(item); + + assert.equal($item.text(), index, 'item text'); + }); +}); diff --git a/testing/tests/DevExpress.ui.widgets/sortable.tests.js b/testing/tests/DevExpress.ui.widgets/sortable.tests.js index b931e59dfb9e..b611b6385e3b 100644 --- a/testing/tests/DevExpress.ui.widgets/sortable.tests.js +++ b/testing/tests/DevExpress.ui.widgets/sortable.tests.js @@ -361,6 +361,24 @@ QUnit.test('option changing', function(assert) { assert.strictEqual(this.$element.children().first().text(), 'item1', 'first item is not changed'); }); +QUnit.test('Move to top if allowReordering is false', function(assert) { + // arrange + const onDragChangeSpy = sinon.spy(); + + this.createSortable({ + allowReordering: false, + dropFeedbackMode: 'indicate', + onDragChange: onDragChangeSpy + }); + + // act + pointerMock(this.$element.children().eq(1)).start().down(15, 45).move(0, -45); + + // assert + assert.strictEqual(onDragChangeSpy.callCount, 0, 'onDragChange event is not called'); + assert.strictEqual($('.dx-sortable-placeholder').length, 0, 'placeholder does not exist'); +}); + QUnit.module('placeholder and source', moduleConfig);