diff --git a/superset-frontend/src/dashboard/components/Dashboard.tsx b/superset-frontend/src/dashboard/components/Dashboard.tsx index 2135a98e442..f468ad3033e 100644 --- a/superset-frontend/src/dashboard/components/Dashboard.tsx +++ b/superset-frontend/src/dashboard/components/Dashboard.tsx @@ -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();