Skip to content

feat: pop out LocationsPanel to separate window (#441)#367

Merged
progressions merged 3 commits into
masterfrom
feature/pop-out-location-panel
Feb 7, 2026
Merged

feat: pop out LocationsPanel to separate window (#441)#367
progressions merged 3 commits into
masterfrom
feature/pop-out-location-panel

Conversation

@progressions

Copy link
Copy Markdown
Owner

Summary

  • Add usePopOutWindow hook that manages opening/closing a child browser window with lifecycle cleanup (polling for close, beforeunload handler, React unmount)
  • Add PopOutWindow component that uses createPortal() with a dedicated Emotion cache + ThemeProvider to render MUI-styled content into the pop-out window
  • Add pop-out button (OpenInNew icon) to the LocationsPanel header controls
  • When popped out, the locations map marker in the MenuBar turns amber to indicate state
  • All React context (EncounterContext, WebSocket, etc.) is shared through the portal — no duplicate connections

Test plan

  • Open encounter page, open locations panel, click pop-out icon — new window opens with LocationsPanel
  • Drag characters between locations in the pop-out — main window updates in real time
  • Create/edit/delete a location in the pop-out window
  • Close the pop-out window — main encounter page returns to normal state
  • Navigate away from the encounter — pop-out window closes automatically
  • Toggle inline locations still works when not popped out
  • Pop-up blocker scenario: blocked window.open shows toast error

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).
Copilot AI review requested due to automatic review settings February 7, 2026 15:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 usePopOutWindow hook to manage the lifecycle of a child window (open/close/cleanup).
  • Adds a PopOutWindow portal 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.

Comment thread src/hooks/usePopOutWindow.ts Outdated
Comment thread src/components/encounters/ShotCounter.tsx Outdated
Comment thread src/hooks/usePopOutWindow.ts
Comment thread src/hooks/usePopOutWindow.ts
Comment thread src/hooks/usePopOutWindow.ts
- 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.
@progressions progressions merged commit a7a54fc into master Feb 7, 2026
4 checks passed
@progressions progressions deleted the feature/pop-out-location-panel branch February 7, 2026 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants