Skip to content

Commit

Permalink
TreeList: Fix the "Uncaught TypeError: this.callBase is not a functio…
Browse files Browse the repository at this point in the history
…n" error occurs with the disabled cacheEnabled option (T1196887) (#25947)

Co-authored-by: Alyar <>
  • Loading branch information
Alyar666 authored Nov 6, 2023
1 parent 20f7d9d commit 6eb9eda
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
3 changes: 2 additions & 1 deletion js/__internal/grids/tree_list/selection/m_selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,12 @@ treeListCore.registerModule('selection', extend(true, {}, selectionModule, {

changeItemSelection(itemIndex, keyboardKeys) {
const isRecursiveSelection = this.isRecursiveSelection();
const callBase = this.callBase.bind(this);

if (isRecursiveSelection && !keyboardKeys.shift) {
const key = this._dataController.getKeyByRowIndex(itemIndex);
return this.selectedItemKeys(key, true, this.isRowSelected(key)).done(() => {
this.isRowSelected(key) && this.callBase(itemIndex, keyboardKeys, true);
this.isRowSelected(key) && callBase(itemIndex, keyboardKeys, true);
});
}

Expand Down
43 changes: 43 additions & 0 deletions testing/tests/DevExpress.ui.widgets.treeList/selection.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1718,5 +1718,48 @@ QUnit.module('Recursive selection', {
assert.strictEqual(items[0].isSelected, undefined, 'selection state of the first item is indeterminate');
assert.strictEqual($(this.rowsView.getRowElement(0)).attr('aria-selected'), 'undefined', 'aria-selected attr with \'undefined\' value');
});

// T1196887
QUnit.test('No exceptions on deselect -> select row when cacheEnabled = false', function(assert) {
// arrange
const $testElement = $('#treeList');
const clock = sinon.useFakeTimers();

this.options.itemsExpr = 'items';
this.options.loadingTimeout = 30;
this.options.cacheEnabled = false;
this.options.dataStructure = 'tree';
this.options.dataSource = new Array(100)
.fill(null)
.map((_, i) => {
return {
id: i + 1,
text: `test${i}`,
items: [{ id: i + 101, text: `test${i + 101}` }]
};
});
this.options.selectedRowKeys = new Array(100).fill(null).map((_, index) => index + 1);
this.setupTreeList();
clock.tick(100);
this.rowsView.render($testElement);

// assert
assert.ok(this.selectionController.isSelectAll(), 'select all state');

try {
// act
this.selectionController.changeItemSelection(0, {});
clock.tick(100);
this.selectionController.changeItemSelection(0, {});
clock.tick(100);

// assert
assert.ok(this.selectionController.isSelectAll(), 'select all state');
} catch(e) {
assert.ok(false, 'exception');
} finally {
clock.restore();
}
});
});

0 comments on commit 6eb9eda

Please sign in to comment.