Skip to content

Commit d05f924

Browse files
List: fix keyboard reordering not working in second and subsequent groups (T1326785) (#33296)
1 parent a8192da commit d05f924

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

packages/devextreme/js/__internal/ui/list/list.edit.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,19 @@ class ListEdit extends ListBase {
6060
}
6161

6262
if (e.shiftKey && itemDragging?.allowReordering) {
63+
if (focusedItemIndex === NOT_EXISTING_INDEX) {
64+
return;
65+
}
66+
6367
const nextItemIndex = focusedItemIndex + (moveUp ? -1 : 1);
6468

65-
if (nextItemIndex < 0
66-
|| nextItemIndex === NOT_EXISTING_INDEX
67-
|| nextItemIndex > this._getLastItemIndex()) {
69+
if (nextItemIndex < 0) {
6870
return;
6971
}
7072

7173
const $nextItem = editStrategy.getItemElement(nextItemIndex);
7274

73-
if (!$nextItem) {
75+
if (!$nextItem?.length) {
7476
return;
7577
}
7678

packages/devextreme/testing/tests/DevExpress.ui.widgets/listParts/editingTests.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,42 @@ QUnit.module('keyboard navigation', {
446446
assert.deepEqual(this.list.option('items'), this.items, 'items are not reordered');
447447
});
448448

449+
QUnit.test('shift+arrowUp should reorder items within second group', function(assert) {
450+
const $secondGroupLastItem = this.$list
451+
.find(`.${LIST_GROUP_CLASS}`).eq(1)
452+
.find(`.${LIST_ITEM_CLASS}`).last();
453+
454+
$secondGroupLastItem.trigger('dxpointerdown');
455+
this.clock.tick(10);
456+
this.keyboard.keyDown('arrowUp', { shiftKey: true });
457+
458+
const expectedItems = [{
459+
items: ['1-1', '1-2'],
460+
}, {
461+
items: ['2-2', '2-1'],
462+
}];
463+
464+
assert.deepEqual(this.list.option('items'), expectedItems, 'items in second group were reordered');
465+
});
466+
467+
QUnit.test('shift+arrowDown should reorder items within second group', function(assert) {
468+
const $secondGroupFirstItem = this.$list
469+
.find(`.${LIST_GROUP_CLASS}`).eq(1)
470+
.find(`.${LIST_ITEM_CLASS}`).first();
471+
472+
$secondGroupFirstItem.trigger('dxpointerdown');
473+
this.clock.tick(10);
474+
this.keyboard.keyDown('arrowDown', { shiftKey: true });
475+
476+
const expectedItems = [{
477+
items: ['1-1', '1-2'],
478+
}, {
479+
items: ['2-2', '2-1'],
480+
}];
481+
482+
assert.deepEqual(this.list.option('items'), expectedItems, 'items in second group were reordered');
483+
});
484+
449485
QUnit.test('shift+arrowDown should not move group header (T1281673)', function(assert) {
450486
const $lastGroupHeader = this.$list.find(`.${LIST_GROUP_HEADER_CLASS}`).last();
451487

0 commit comments

Comments
 (0)