mirror of
https://github.com/apache/superset.git
synced 2026-05-21 15:55:10 +00:00
fix(Dashboard): attach visibilitychange listener to document
The visibilitychange event is dispatched on document, not window, so listening on window prevented browser-tab hide/show logging from firing.
This commit is contained in:
@@ -296,11 +296,11 @@ function Dashboard({
|
||||
ts: new Date().getTime(),
|
||||
};
|
||||
}
|
||||
window.addEventListener('visibilitychange', onVisibilityChange);
|
||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
||||
|
||||
// componentWillUnmount equivalent
|
||||
return () => {
|
||||
window.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
document.removeEventListener('visibilitychange', onVisibilityChange);
|
||||
onBeforeUnload(false); // Remove beforeunload listener on unmount
|
||||
actions.clearDataMaskState();
|
||||
actions.clearAllChartStates();
|
||||
|
||||
Reference in New Issue
Block a user