Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TreeList: Fix getSelectedRowsData method when calling navigateToRow in the onNodesInitialized event (T858312) #11904

Merged
merged 1 commit into from
Feb 6, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/ui/tree_list/ui.tree_list.data_source_adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,9 @@ let DataSourceAdapterTreeList = DataSourceAdapter.inherit((function() {
if(options.collapseVisibleNodes || expandedRowKeys.length) {
this.option('expandedRowKeys', expandedRowKeys);
}
this._isReload = false;
this.executeAction('onNodesInitialized', { root: this._rootNode });
this._isNodesInitializing = false;
this._isReload = false;
}

data = this._createVisibleItemsByNodes(this._rootNode.children, options);
Expand Down
34 changes: 33 additions & 1 deletion testing/tests/DevExpress.ui.widgets.treeList/selection.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const setupModule = function() {
};

that.setupTreeList = function() {
setupTreeListModules(that, ['data', 'columns', 'rows', 'selection', 'editorFactory', 'columnHeaders', 'filterRow', 'sorting', 'search'], {
setupTreeListModules(that, ['data', 'columns', 'rows', 'selection', 'editorFactory', 'columnHeaders', 'filterRow', 'sorting', 'search', 'focus'], {
initViews: true
});
};
Expand Down Expand Up @@ -497,6 +497,38 @@ QUnit.test('selection for nested node should works', function(assert) {
assert.strictEqual(this.getVisibleRows()[1].isSelected, true, 'row 1 is selected');
});

// T858312
QUnit.test('The getSelectedRowsData method should work correctly when calling navigateToRow in the onNodesInitialized event', function(assert) {
// arrange
const $testElement = $('#treeList');
const clock = sinon.useFakeTimers();

this.options.loadingTimeout = 30;
this.options.autoNavigateToFocusedRow = true;
this.options.onNodesInitialized = (e) => {
this.navigateToRow(2);
};

this.setupTreeList();
clock.tick(60);
this.rowsView.render($testElement);

// assert
assert.ok(this.getNodeByKey(1), 'node with key "1" exists');
assert.ok(this.getNodeByKey(2), 'node with key "2" exists');

// act
this.selectRows(2);

// assert
assert.deepEqual(this.getSelectedRowKeys(), [2], 'getSelectedRowKeys');
assert.deepEqual(this.option('selectedRowKeys'), [2], 'selectedRowKeys');
assert.deepEqual(this.getSelectedRowsData(), [{ id: 2, parentId: 1, field1: 'test2', field2: 2, field3: new Date(2002, 1, 2) }], 'getSelectedRowsData');

clock.restore();
});


QUnit.module('Recursive selection', {
beforeEach: function() {
setupModule.call(this);
Expand Down