From 23583a78a954bc0f3ce34d84ff30cb39f74b17a4 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Fri, 21 Aug 2026 14:16:50 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B(frontend)=20use=20state=20instead?= =?UTF-8?q?=20of=20a=20ref=20for=20MoreControls=20container?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After the recent refactoring, `MoreControls` only renders once. On that first render, the container ref is `null`, and when it later gets a reference to the div, the ref update does not trigger a re-render. As a result, the additional controls were never showing up. Switch from a ref to a state to track the container element. State updates do trigger a re-render, so the controls now show as expected once the container is available. --- .../prefabs/ControlBar/DesktopControlBar.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/frontend/src/features/rooms/livekit/prefabs/ControlBar/DesktopControlBar.tsx b/src/frontend/src/features/rooms/livekit/prefabs/ControlBar/DesktopControlBar.tsx index 975b8338..fe2d70a4 100644 --- a/src/frontend/src/features/rooms/livekit/prefabs/ControlBar/DesktopControlBar.tsx +++ b/src/frontend/src/features/rooms/livekit/prefabs/ControlBar/DesktopControlBar.tsx @@ -9,7 +9,7 @@ import { SubtitlesToggle } from '../../components/controls/SubtitlesToggle' import { OptionsButton } from '../../components/controls/Options/OptionsButton' import { StartMediaButton } from '../../components/controls/StartMediaButton' import { MoreOptions } from './MoreOptions' -import { useRef } from 'react' +import { RefObject, useMemo, useState } from 'react' import { useRegisterKeyboardShortcut } from '@/features/shortcuts/useRegisterKeyboardShortcut' import { useFullScreen } from '../../hooks/useFullScreen' import { VideoDeviceControl } from '../../components/controls/Device/VideoDeviceControl' @@ -21,7 +21,14 @@ export function DesktopControlBar({ onDeviceError, }: Readonly) { const browserSupportsScreenSharing = supportsScreenSharing() - const desktopControlBarEl = useRef(null) + + const [controlBarElement, setControlBarElement] = + useState(null) + + const desktopControlBarEl = useMemo>( + () => ({ current: controlBarElement }), + [controlBarElement] + ) const { toggleFullScreen, isFullscreenAvailable } = useFullScreen({}) @@ -45,7 +52,7 @@ export function DesktopControlBar({ return (