Skip to content

Commit

Permalink
TreeList: Fix navigateTo to the same page with row expanding after #1…
Browse files Browse the repository at this point in the history
  • Loading branch information
vconst authored Feb 5, 2020
1 parent 47a35ac commit 943c7ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
16 changes: 13 additions & 3 deletions js/ui/grid_core/ui.grid_core.focus.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,19 @@ exports.FocusController = core.ViewController.inherit((function() {
d.resolve(-1);
return;
}
dataController.pageIndex(pageIndex).done(function() {
that._navigateTo(key, d, needFocusRow);
}).fail(d.reject);
if(pageIndex === dataController.pageIndex()) {
dataController.reload().done(function() {
if(that.isRowFocused(key)) {
d.resolve(that.getFocusedRowIndexByKey(key));
} else {
that._navigateTo(key, d, needFocusRow);
}
}).fail(d.reject);
} else {
dataController.pageIndex(pageIndex).done(function() {
that._navigateTo(key, d, needFocusRow);
}).fail(d.reject);
}
}).fail(d.reject);
}

Expand Down
21 changes: 21 additions & 0 deletions testing/tests/DevExpress.ui.widgets.treeList/treeList.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1403,10 +1403,31 @@ QUnit.test('TreeList navigateTo', function(assert) {
this.clock.tick();

// assert
assert.deepEqual(treeList.option('expandedRowKeys'), [11], 'parent node is expanded');
assert.equal(treeList.pageIndex(), 1, 'page is changed');
assert.ok(treeList.getRowIndexByKey(12) >= 0, 'key is visible');
});

QUnit.test('TreeList navigateTo to the same page with expand', function(assert) {
// arrange, act
const treeList = createTreeList({
dataSource: generateData(10),
paging: {
pageSize: 4
}
});

this.clock.tick();

treeList.navigateToRow(2);
this.clock.tick();

// assert
assert.deepEqual(treeList.option('expandedRowKeys'), [1], 'parent node is expanded');
assert.equal(treeList.pageIndex(), 0, 'page is not changed');
assert.ok(treeList.getRowIndexByKey(2) >= 0, 'key is visible');
});

// T697860
QUnit.test('dataSource change with columns should force one loading only', function(assert) {
const loadingSpy = sinon.spy();
Expand Down

0 comments on commit 943c7ee

Please sign in to comment.