diff --git a/fluxer_app/src/features/ui/commands/ModalCommands.ts b/fluxer_app/src/features/ui/commands/ModalCommands.ts index 9e70e1ad8..4e0807a46 100644 --- a/fluxer_app/src/features/ui/commands/ModalCommands.ts +++ b/fluxer_app/src/features/ui/commands/ModalCommands.ts @@ -21,11 +21,16 @@ const isBackgroundModal = (element: React.ReactElement): boolean => { return BACKGROUND_MODAL_TYPES.some((type) => element.type === type); }; const getCommandOwnerDocument = (): Document => getActivePortalHost()?.ownerDocument ?? document; -const getPushOptions = (isBackground: boolean) => ({ - isBackground, - forceMainWindow: isBackground, - portalHost: isBackground ? null : getActivePortalHost(), -}); +const getPushOptions = (isBackground: boolean) => { + const activePortalHost = getActivePortalHost(); + const isPoppedOut = activePortalHost?.ownerDocument !== document; + const forceMainWindow = isBackground && isPoppedOut; + return { + isBackground, + forceMainWindow, + portalHost: forceMainWindow ? null : activePortalHost, + }; +}; export function modal(render: () => React.ReactElement): ModalRender { return render as ModalRender;