Files
streamyfin/components/video-player/controls/contexts/ControlsContext.tsx
Gauvino ac0018092a fix(player): re-enable controls auto-hide, keep open while settings popover is open
Tapping to reveal the controls showed them permanently — they never auto-hid
after the inactivity timeout (CONTROLS_CONSTANTS.TIMEOUT). Root cause:
useControlsTimeout was called with a hardcoded disabled: true (introduced in
the KSPlayer work in #1266), so the auto-hide timer was never armed.

Simply removing that override re-introduced a regression on iOS: the timer
fired while the settings popover was open, dismissing it mid-interaction
(subtitle / audio / speed selection), because on iOS the popover lives inside
the controls and closes when they fade out.

Surface the popover's open state through a small ControlsContext (rather than
prop drilling through HeaderControls) and feed it to useControlsTimeout's
disabled flag, so auto-hide pauses while the menu is open and re-arms once it
closes. Android's menu is a separate global bottom-sheet modal, unaffected.

Fixes #1243. Regression from #1266. Depends on #1621.
2026-06-16 11:27:14 +02:00

27 lines
744 B
TypeScript

import { createContext, useContext } from "react";
interface ControlsContextProps {
/**
* Lets descendants (e.g. the settings popover) pause the controls auto-hide
* while an interactive menu is open, so it can't be dismissed out from under
* the user. Mirrors the `settingsMenuOpen` state owned by `Controls`.
*/
setSettingsMenuOpen: (open: boolean) => void;
}
const ControlsContext = createContext<ControlsContextProps | undefined>(
undefined,
);
export const ControlsProvider = ControlsContext.Provider;
export const useControlsContext = () => {
const ctx = useContext(ControlsContext);
if (!ctx) {
throw new Error(
"useControlsContext must be used within a ControlsProvider",
);
}
return ctx;
};