diff --git a/src/frontend/src/features/rooms/livekit/hooks/useScreenSharePopout.ts b/src/frontend/src/features/rooms/livekit/hooks/useScreenSharePopout.ts index c7de292a9..8b9314a55 100644 --- a/src/frontend/src/features/rooms/livekit/hooks/useScreenSharePopout.ts +++ b/src/frontend/src/features/rooms/livekit/hooks/useScreenSharePopout.ts @@ -89,7 +89,13 @@ export const useScreenSharePopout = ({ reportError('generic_failure', error, { context: 'screen_share_popout_init', }) - next.close() + // The open may already have cleared the pin and stored the window. + // Closing it alone would leave the meeting unpinned. + if (screenSharePopoutStore.entry) { + closeScreenSharePopout({ restorePin: true }) + } else { + next.close() + } } }, [announce, getVideoElement, release, t, title, trackSid, windowName])