# LIVE NAVIGATION – Bug Fix Log

| Date | File | Issues Addressed | Status |
|------|------|------------------|--------|
| 2025-11-09 | `apps/web/src/modules/map/pages/MapPage.mobile.vue` | Browser globals, network listeners, event bus emissions | ✅ Fixed |

## Fix Categories

| # | Category | Scope | Details |
|---|----------|-------|---------|
| 1 | **Browser-safe globals** | `shareTextPayload`, invite links, lifecycle hooks | Added `hasDomEnvironment`, `runtimeWindow`, `runtimeNavigator` helpers. Replaced every direct `window`/`navigator` reference (11 + 6 usages) so SSR/hydration no longer trigger `no-restricted-globals` and clipboard/share fall back cleanly. |
| 2 | **Interval & resize guards** | `onMounted`, `clearTimeTicker`, `handleWindowResize` | `setInterval/clearInterval` now use `globalThis`, and resize listeners are only registered when DOM APIs exist, preventing timers from leaking in tests or SSR. |
| 3 | **Network listeners** | `applyNetworkListeners`, `removeNetworkListeners` | Handlers are stored and removed symmetrically (previous code registered inline callbacks but removed different functions, leaving phantom listeners). |
| 4 | **Event bus emissions** | `openPlanner`, `openExplore` | Removed redundant `void` operator; events now emit normally and keep inferred return types. |
| 5 | **Invite/share clipboard** | `handleInviteToSession`, share fallback | Clipboard + share logic uses `runtimeNavigator?.clipboard` so failures are handled consistently without throwing in non-browser contexts. |

## Verification

| Check | Result | Notes |
|-------|--------|-------|
| ESLint (targeted) | ✅ | `pnpm exec eslint apps/web/src/modules/map/pages/MapPage.mobile.vue` |
| TypeScript | ⚪ Not run | Run `pnpm type-check` for full safety |
| Manual review | ✅ | Verified that `rg "window"` and `rg "navigator"` report only guarded helpers inside MapPage |

## Follow-up

| Concern | Recommendation |
|---------|----------------|
| Global helpers reuse | Move `runtimeWindow/runtimeNavigator` helpers into a shared utility if other mobile pages need them |
| Tests | Add regression test to ensure network listeners detach when component unmounts |
