feat: pop out LocationsPanel to separate window (#441)#367
Merged
Conversation
Allow GM to pop out the locations panel into a separate browser window for screen-sharing while keeping the main encounter view for combat. Uses window.open() + createPortal() to render in a new window while sharing all React context (EncounterContext, WebSocket, etc).
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a “pop-out” capability for the Encounters Locations panel, rendering the existing LocationsPanel UI into a separate browser window via a portal while keeping React context shared with the main window.
Changes:
- Introduces a
usePopOutWindowhook to manage the lifecycle of a child window (open/close/cleanup). - Adds a
PopOutWindowportal component with a dedicated Emotion cache + MUI theming for correct styling in the new window. - Updates encounter UI (LocationsPanel header, ShotCounter wiring, and MenuBar indicator) to support opening locations in a separate window and reflecting popped-out state.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/hooks/usePopOutWindow.ts | New hook that opens/manages a child window and provides a portal container element. |
| src/hooks/index.ts | Re-exports the new usePopOutWindow hook. |
| src/components/ui/PopOutWindow.tsx | New portal component that renders children into the pop-out window with MUI/Emotion support. |
| src/components/encounters/locations/LocationsPanel.tsx | Adds a pop-out button and adjusts layout/controls when rendered in a popped-out context. |
| src/components/encounters/ShotCounter.tsx | Wires up pop-out behavior, toast on popup-blocked, and switches between inline vs pop-out rendering. |
| src/components/encounters/MenuBar.tsx | Adds a visual indicator (amber marker) when locations are popped out. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Use beforeunload/unload listeners on child window for faster close detection, with slower 2s fallback poll instead of 500ms polling-only - Return existing window ref when focusing (not undefined), clean up return type to Window | null - Handle blocked popup in isPoppedOut path — fall back to inline panel
Covers popup blocked path, cleanup on close, unmount cleanup, focus existing window, polling fallback, and lifecycle event listeners.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
usePopOutWindowhook that manages opening/closing a child browser window with lifecycle cleanup (polling for close, beforeunload handler, React unmount)PopOutWindowcomponent that usescreatePortal()with a dedicated Emotion cache + ThemeProvider to render MUI-styled content into the pop-out windowTest plan