Skip to content

Commit 9ff69ab

Browse files
testcafe
1 parent cb9cbf1 commit 9ff69ab

File tree

1 file changed

+76
-1
lines changed

1 file changed

+76
-1
lines changed

e2e/testcafe-devextreme/tests/dataGrid/common/keyboardNavigation/keyboardNavigation.functional.ts

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
resetFocusedEventsTestData,
1919
} from '../../helpers/eventUtils';
2020
import { testScreenshot } from '../../../../helpers/themeUtils';
21-
import { addFocusableElementBefore } from '../../../../helpers/domUtils';
21+
import { addFocusableElementBefore, getDocumentScrollTop } from '../../../../helpers/domUtils';
2222

2323
const CLASS = ClassNames;
2424

@@ -6640,3 +6640,78 @@ test('Focus should be set to the grid to allow keyboard navigation when the focu
66406640
},
66416641
}, '#otherContainer');
66426642
});
6643+
6644+
test('Browser should not scroll back to the grid when a focused cell is updated or rerendered (T1310557)', async (t) => {
6645+
// arrange
6646+
const dataGrid = new DataGrid('#container');
6647+
const firstCell = dataGrid.getDataCell(0, 0);
6648+
const secondCell = dataGrid.getDataCell(0, 1);
6649+
6650+
// assert
6651+
await t.expect(dataGrid.isReady()).ok();
6652+
6653+
// act
6654+
await t
6655+
.click(firstCell.element)
6656+
.pressKey('tab');
6657+
6658+
// assert
6659+
await t.expect(secondCell.element.focused).ok();
6660+
6661+
// act
6662+
await ClientFunction(() => {
6663+
window.scrollTo(0, 300);
6664+
})();
6665+
6666+
// assert
6667+
await t.expect(getDocumentScrollTop()).eql(300);
6668+
6669+
// act
6670+
await dataGrid.apiPush([{
6671+
type: 'update',
6672+
key: 1,
6673+
data: { name: 'updated' },
6674+
}]);
6675+
6676+
// assert
6677+
await t
6678+
.expect(secondCell.element.textContent)
6679+
.eql('updated')
6680+
.expect(getDocumentScrollTop())
6681+
.eql(300);
6682+
6683+
// act
6684+
await dataGrid.apiRefresh();
6685+
6686+
// assert
6687+
await t.expect(getDocumentScrollTop()).eql(300);
6688+
6689+
// act
6690+
await dataGrid.repaint();
6691+
6692+
// assert
6693+
await t.expect(getDocumentScrollTop()).eql(300);
6694+
6695+
// act
6696+
await t.pressKey('left');
6697+
6698+
// assert
6699+
await t
6700+
.expect(firstCell.isFocused)
6701+
.ok()
6702+
.expect(getDocumentScrollTop())
6703+
.eql(0);
6704+
}).before(async () => {
6705+
await ClientFunction(() => {
6706+
$('#container').css('padding-bottom', '1000px');
6707+
})();
6708+
6709+
await createWidget('dxDataGrid', {
6710+
dataSource: [{ id: 1, name: 'test1' }],
6711+
keyExpr: 'id',
6712+
});
6713+
}).after(async () => {
6714+
await ClientFunction(() => {
6715+
$('#container').css('padding-bottom', '');
6716+
})();
6717+
});

0 commit comments

Comments
 (0)