From 4bfd7c348d8a4b8d34c8541f1481a7fe25f570d5 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sun, 5 Nov 2023 12:42:30 +0100 Subject: [PATCH] Unfocus control elements when controls hides --- front/packages/ui/src/player/index.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/front/packages/ui/src/player/index.tsx b/front/packages/ui/src/player/index.tsx index 4e3e8339..1ab7f317 100644 --- a/front/packages/ui/src/player/index.tsx +++ b/front/packages/ui/src/player/index.tsx @@ -163,6 +163,14 @@ export const Player: QueryPage<{ slug: string; type: "episode" | "movie" }> = ({ setPlay(!isPlaying); }; + // When the controls hide, remove focus so space can be used to play/pause instead of triggering the button + // It also serves to hide the tooltip. + useEffect(() => { + if (Platform.OS !== "web") return; + if (!displayControls && document.activeElement instanceof HTMLElement) + document.activeElement.blur(); + }, [displayControls]); + if (error || infoError || playbackError) return ( <>