fix(web): exit slideshow when exiting fullscreen. (#19247)

Exit slideshow when exiting fullscreen.

Browsers do not send a keyboard event when exiting fullscreen, so if
the user exits fullscreen with the escape key, the slideshow
remains open, requiring another escape key press to close it. Fix this
by listening for the fullscreenchange event and closing the slideshow
when exiting fullscreen.
This commit is contained in:
Dag Stuan 2025-06-19 16:10:10 +02:00 committed by GitHub
parent caf11fbb96
commit 38e68d16f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -108,6 +108,30 @@
}
await modalManager.show(SlideshowSettingsModal);
};
onMount(() => {
function exitFullscreenHandler() {
const doc = document as Document & {
webkitIsFullScreen?: boolean;
};
if (
// eslint-disable-next-line tscompat/tscompat
!document.fullscreenElement &&
!doc.webkitIsFullScreen
) {
onClose();
}
}
document.addEventListener('fullscreenchange', exitFullscreenHandler);
document.addEventListener('webkitfullscreenchange', exitFullscreenHandler);
return () => {
document.removeEventListener('fullscreenchange', exitFullscreenHandler);
document.removeEventListener('webkitfullscreenchange', exitFullscreenHandler);
};
});
</script>
<svelte:document