Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/devextreme/js/__internal/ui/list/list.edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,19 @@ class ListEdit extends ListBase {

if (e.shiftKey && itemDragging?.allowReordering) {
const nextItemIndex = focusedItemIndex + (moveUp ? -1 : 1);

if (nextItemIndex < 0
|| nextItemIndex === NOT_EXISTING_INDEX
|| nextItemIndex > this._getLastItemIndex()) {
return;
}

const $nextItem = editStrategy.getItemElement(nextItemIndex);

if (!$nextItem) {
return;
}

const isMoveFromGroup = grouped
&& $(focusedElement).parent().get(0) !== $nextItem.parent().get(0);
if (!isMoveFromGroup) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,62 @@ QUnit.module('keyboard navigation', {
assert.deepEqual(list.option('items'), items, 'items were reordered');
});

QUnit.test('shift+arrowUp on first item should not throw error (T1320189)', function(assert) {
const items = ['1', '2', '3'];

const $list = $('#list').dxList({
items: items,
editEnabled: true,
itemDragging: {
allowReordering: true
},
focusStateEnabled: true
});

const list = $list.dxList('instance');
const keyboard = keyboardMock($list.find('[tabindex=0]'));

const $firstItem = $list.find('.' + LIST_ITEM_CLASS).eq(0);
list.option('focusedElement', $firstItem.get(0));

let errorMessage = '';
try {
keyboard.keyDown('arrowUp', { shiftKey: true });
} catch(e) {
errorMessage = `error message: ${e.message}`;
}

assert.strictEqual(errorMessage, '', 'no error thrown when trying to move first item up');
});

QUnit.test('shift+arrowDown on last item should not throw error (T1320189)', function(assert) {
const items = ['1', '2', '3'];

const $list = $('#list').dxList({
items: items,
editEnabled: true,
itemDragging: {
allowReordering: true
},
focusStateEnabled: true
});
const list = $list.dxList('instance');
const keyboard = keyboardMock($list.find('[tabindex=0]'));

const $lastItem = $list.find('.' + LIST_ITEM_CLASS).eq(2);
list.option('focusedElement', $lastItem.get(0));

let errorMessage = '';
try {
keyboard.keyDown('arrowDown', { shiftKey: true });
} catch(e) {
errorMessage = `error message: ${e.message}`;
}

assert.strictEqual(errorMessage, '', 'no error thrown when trying to move last item down');
});


QUnit.module('grouped', {
beforeEach: function() {
this.getInitialItems = () => {
Expand Down
Loading