Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tucchhaa committed Jan 10, 2025
1 parent a9477fc commit 3489c11
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4384,6 +4384,43 @@ QUnit.module('View\'s focus', {
assert.equal(this.dataGrid.option('focusedRowKey'), 2, 'row key is changed');
assert.ok($(this.dataGrid.getRowElement(1)).hasClass('dx-row-focused'), 'second row is focused');
});

// T1224663
['onFocusedRowChanged', 'onFocusedRowChanging'].forEach(event => {
QUnit.testInActiveWindow(`Focus should be preserved on datagrid when rowsview repaints in ${event} event`, function(assert) {
// arrange
this.dataGrid.option({
dataSource: [
{ id: 1, name: 'name 1' },
{ id: 2, name: 'name 2' },
{ id: 3, name: 'name 3' }
],
keyExpr: 'id',
focusedRowEnabled: true,
[event]: (e) => {
this.dataGrid.repaint();
}
});
this.clock.tick(300);

// act
$(this.dataGrid.getCellElement(0, 0)).trigger(CLICK_EVENT);
this.clock.tick(300);

// assert
const firstRow = $(this.dataGrid.getRowElement(0));
assert.ok(firstRow.hasClass('dx-row-focused'), 'first row is focused');

// act
const keyboard = keyboardMock(firstRow);
keyboard.keyDown('down');
this.clock.tick(300);

// assert
const secondRow = $(this.dataGrid.getRowElement(1));
assert.ok(secondRow.hasClass('dx-row-focused'), 'second row is focused');
});
});
});

QUnit.module('API methods', baseModuleConfig, () => {
Expand Down

0 comments on commit 3489c11

Please sign in to comment.