Skip to content
Open
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
4 changes: 4 additions & 0 deletions packages/devextreme/js/__internal/ui/list/list.edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class ListEdit extends ListBase {
const nextItemIndex = focusedItemIndex + (moveUp ? -1 : 1);
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,53 @@ QUnit.module('keyboard navigation', {
assert.deepEqual(list.option('items'), items, 'items were reordered');
});

QUnit.test('shift+arrowUp on first item should not throw error', function(assert) {
Copy link
Contributor

@pharret31 pharret31 Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see the test that would check if error isn't thrown, could you please add it to make the test title and its body connected? As well as for the second test, to make that I suppose you can use sinon methods smth like:

const consoleSpy = sinon.spy(console, 'error');
...
assert.strictEqual(consoleSpy.callCount, 0, 'no error messages in console');

because currently it seems that old behaviour would pass these tests as well since before items order wasn't changed too, isn't it?
also you can actually combine them in one using forEach syntax

or

if this behaviour actually throws an error it could be handled by standard QUnit methods

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);
$firstItem.trigger('dxpointerdown');
this.clock.tick(10);

keyboard.keyDown('arrowUp', { shiftKey: true });

assert.deepEqual(list.option('items'), items, 'items order is unchanged');
});

QUnit.test('shift+arrowDown on last item should not throw error', 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);
$lastItem.trigger('dxpointerdown');
this.clock.tick(10);

keyboard.keyDown('arrowDown', { shiftKey: true });

assert.deepEqual(list.option('items'), items, 'items order is unchanged');
});


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