disable focus on button, enable focus to iframe

whe fullscreen state changes
fix fullscreen
This commit is contained in:
DmitriyB
2023-02-15 15:45:55 +05:00
parent 40c9cf2fe1
commit e603b5bbb1
4 changed files with 5 additions and 39 deletions
@@ -33,9 +33,9 @@ export const PlayerComponent: React.FC<any> = ({ closeStream }) => {
return (
<>
<iframe
id='player'
title="stream"
src={url}
allowFullScreen
className={"player playerOn"}
security={""}
></iframe>
@@ -4,12 +4,9 @@ import { Button } from "../button/button";
import fullscreen from "../../../images/icons/fullscreen.svg";
import fullscreenOff from "../../../images/icons/fullscreenOff.svg";
import { FullScreen, useFullScreenHandle } from "react-full-screen";
export const FullscreenButton = ({ }) => {
const handle = useFullScreenHandle();
const player = document.getElementById('player') // set focus to element after fullscreen state changed, otherwise keyboard doesn't work in iframe
const [active, setActive] = useState(Boolean(document.fullscreenElement));
const [button, setButton] = useState({
icon: fullscreen,
@@ -30,6 +27,9 @@ export const FullscreenButton = ({ }) => {
}
useEffect(() => {
if (player) {
player.focus()
}
setButton({
icon: active ? fullscreen : fullscreenOff,
inactive: "fullscreen-control-btn",