diff --git a/src/ConferenceCallManagerHooks.js b/src/ConferenceCallManagerHooks.js index 2febec3..154fa35 100644 --- a/src/ConferenceCallManagerHooks.js +++ b/src/ConferenceCallManagerHooks.js @@ -150,11 +150,18 @@ export function useVideoRoom(manager, roomId, timeout = 5000) { })); function onBeforeUnload(event) { + if ( + event.type === "visibilitychange" && + document.visibilityState === "visible" + ) { + return; + } + manager.leaveCall(); } // iOS doesn't fire beforeunload event, so leave the call when you hide the page. - const unloadEvent = isIOS() ? "pagehide" : "beforeunload"; + const unloadEvent = isIOS() ? "visibilitychange" : "beforeunload"; window.addEventListener(unloadEvent, onBeforeUnload);