diff --git a/packages/devextreme/js/__internal/grids/grid_core/state_storing/m_state_storing_core.ts b/packages/devextreme/js/__internal/grids/grid_core/state_storing/m_state_storing_core.ts index f4f57006553d..5db0ddc0b4c1 100644 --- a/packages/devextreme/js/__internal/grids/grid_core/state_storing/m_state_storing_core.ts +++ b/packages/devextreme/js/__internal/grids/grid_core/state_storing/m_state_storing_core.ts @@ -80,7 +80,7 @@ export class StateStoringController extends modules.ViewController { } }; - eventsEngine.on(getWindow(), 'unload', this._windowUnloadHandler); + eventsEngine.on(getWindow(), 'visibilitychange', this._windowUnloadHandler); return this; // needed by pivotGrid mocks } @@ -103,7 +103,7 @@ export class StateStoringController extends modules.ViewController { public dispose() { clearTimeout(this._savingTimeoutID); - eventsEngine.off(getWindow(), 'unload', this._windowUnloadHandler); + eventsEngine.off(getWindow(), 'visibilitychange', this._windowUnloadHandler); } private _loadState() { diff --git a/packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/stateStoring.tests.js b/packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/stateStoring.tests.js index 103bff0cdfc3..1ee65154aa5a 100644 --- a/packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/stateStoring.tests.js +++ b/packages/devextreme/testing/tests/DevExpress.ui.widgets.dataGrid/stateStoring.tests.js @@ -77,7 +77,7 @@ QUnit.module('Local storage', { assert.ok(!localStorage.getItem('TestNameSpace'), 'state not saved'); // act - $(window).trigger('unload'); + $(window).trigger('visibilitychange'); // assert assert.equal(parseInt(JSON.parse(localStorage.getItem('TestNameSpace')).testSetting), 107, 'state saved');