diff --git a/e2e/testcafe-devextreme/tests/dataGrid/stateStoring/stateStoring.ts b/e2e/testcafe-devextreme/tests/dataGrid/stateStoring/stateStoring.ts index 4fef2309d598..c817b1abdd83 100644 --- a/e2e/testcafe-devextreme/tests/dataGrid/stateStoring/stateStoring.ts +++ b/e2e/testcafe-devextreme/tests/dataGrid/stateStoring/stateStoring.ts @@ -82,3 +82,31 @@ test('The rows should render correctly when cellTemplates are used and the selec // simulating async rendering in React await makeRowsViewTemplatesAsync(GRID_CONTAINER); }); + +test('The focused state of a row with the 0 key should be restored (T1252962)', async (t) => { + const dataGrid = new DataGrid('#container'); + const dataRow0 = dataGrid.getDataRow(0); + + // assert + await t + .expect(dataGrid.isReady()) + .ok() + .expect(dataRow0.isFocusedRow) + .ok(); +}).before(async () => createWidget('dxDataGrid', { + dataSource: [ + { id: 0, text: 'item 1' }, + { id: 1, text: 'item 2' }, + ], + keyExpr: 'id', + focusedRowEnabled: true, + stateStoring: { + enabled: true, + type: 'custom', + customLoad() { + return Promise.resolve({ + focusedRowKey: 0, + }); + }, + }, +})); diff --git a/packages/devextreme/js/__internal/grids/grid_core/state_storing/m_state_storing.ts b/packages/devextreme/js/__internal/grids/grid_core/state_storing/m_state_storing.ts index d2c1234c692d..2179236f5b45 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/state_storing/m_state_storing.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/state_storing/m_state_storing.ts @@ -190,7 +190,7 @@ const stateStoring = (Base: ModuleType) => class StateSt if (this.option('focusedRowEnabled')) { this.option('focusedRowIndex', -1); - this.option('focusedRowKey', state.focusedRowKey || null); + this.option('focusedRowKey', state.focusedRowKey ?? null); } this.component.endUpdate();