Skip to content

Commit

Permalink
DataGrid - Move from depeceted 'unload' event to 'visibilitychange' (… (
Browse files Browse the repository at this point in the history
#28049)

Co-authored-by: Sergey Arzamasov <[email protected]>
  • Loading branch information
siarhei-arzamasau and Sergey Arzamasov authored Sep 13, 2024
1 parent 01b0042 commit e617949
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit e617949

Please sign in to comment.