From 6d5effb74cc9a0d3925fa47bcf6bc3e5bbd5b403 Mon Sep 17 00:00:00 2001 From: zurdi Date: Thu, 10 Sep 2026 17:17:19 +0200 Subject: [PATCH] fix(player): keep RomM chrome off the emulator on mobile Since 5.0.0 the fixed v2 nav chrome (logo, user menu, tab bar) painted over the EmulatorJS UI on phones: the running stage's z-index traps the emulator's own layers below the nav, the iOS fullscreen shim's nav-hiding selectors only matched v1 classes, and EmulatorJS's corner menu button sat flush against rounded screen corners while overlapping the virtual R shoulder button. Touches on the virtual gamepad's empty zones also synthesized mouse events that ghost-opened the emulator menu between the A and B buttons (EmulatorJS/EmulatorJS#1221). Players now mirror their running stage into a stageActive store flag (PlayerShell owns it for Ruffle/JsDos/Pico8; EmulatorJS and Stream wire their own): AppLayout unmounts AppNav/BottomNav while it is set and mirrors it onto , where global.css zeroes --r-nav-h and --r-bottom-nav-h so stages, dialogs, menus, and toasts reclaim the space through the tokens they already consume. The flag is deliberately separate from `playing`, which also spans Stream's loading phase while the config screen still needs the nav, and stays unset in the admin Desktop view. A stage-scoped touchstart guard cancels empty-zone touches, and the menu button gets corner margin plus a 44px target. Fixes #4081 Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01ND1wfNV3vKwu8Mfinn4WkA --- frontend/src/stores/playing.ts | 6 +++ .../v2/components/Player/PlayerShell.test.ts | 19 ++++++++- .../src/v2/components/Player/PlayerShell.vue | 4 ++ .../v2/composables/useStageActive/index.ts | 32 +++++++++++++++ frontend/src/v2/layouts/AppLayout.vue | 11 +++++- frontend/src/v2/styles/global.css | 7 ++++ .../src/v2/utils/playerTouchGuard.test.ts | 39 +++++++++++++++++++ frontend/src/v2/utils/playerTouchGuard.ts | 21 ++++++++++ frontend/src/v2/views/Player/EmulatorJS.vue | 24 ++++++++++-- frontend/src/v2/views/Player/JsDos.test.ts | 6 ++- frontend/src/v2/views/Player/Ruffle.test.ts | 6 ++- frontend/src/v2/views/Player/Stream.vue | 4 ++ 12 files changed, 171 insertions(+), 8 deletions(-) create mode 100644 frontend/src/v2/composables/useStageActive/index.ts create mode 100644 frontend/src/v2/utils/playerTouchGuard.test.ts create mode 100644 frontend/src/v2/utils/playerTouchGuard.ts diff --git a/frontend/src/stores/playing.ts b/frontend/src/stores/playing.ts index e265cb2da..d3c346ac5 100644 --- a/frontend/src/stores/playing.ts +++ b/frontend/src/stores/playing.ts @@ -4,6 +4,9 @@ export default defineStore("playing", { state: () => ({ playing: false, fullScreen: false, + // True while a player's running stage covers the viewport; the v2 + // AppLayout unmounts the nav chrome and zeroes the nav-height tokens. + stageActive: false, }), actions: { @@ -13,5 +16,8 @@ export default defineStore("playing", { setFullScreen(fullScreen: boolean) { this.fullScreen = fullScreen; }, + setStageActive(stageActive: boolean) { + this.stageActive = stageActive; + }, }, }); diff --git a/frontend/src/v2/components/Player/PlayerShell.test.ts b/frontend/src/v2/components/Player/PlayerShell.test.ts index cbb364d29..518ccecae 100644 --- a/frontend/src/v2/components/Player/PlayerShell.test.ts +++ b/frontend/src/v2/components/Player/PlayerShell.test.ts @@ -3,12 +3,16 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import type { SimpleRom } from "@/stores/roms"; import PlayerShell from "./PlayerShell.vue"; -const mocks = vi.hoisted(() => ({ push: vi.fn() })); +const mocks = vi.hoisted(() => ({ push: vi.fn(), setStageActive: vi.fn() })); vi.mock("vue-i18n", () => ({ useI18n: () => ({ t: (key: string) => key }), })); +vi.mock("@/stores/playing", () => ({ + default: () => ({ setStageActive: mocks.setStageActive }), +})); + vi.mock("vue-router", () => ({ useRouter: () => ({ push: mocks.push }), })); @@ -59,6 +63,7 @@ function mountShell( beforeEach(() => { mocks.push.mockReset(); + mocks.setStageActive.mockReset(); }); describe("PlayerShell", () => { @@ -133,4 +138,16 @@ describe("PlayerShell", () => { wrapper.get(".r-v2-player__quit").attributes("disabled"), ).toBeDefined(); }); + + it("mirrors the running stage into the global chrome flag", async () => { + const wrapper = mountShell({ running: true }); + expect(mocks.setStageActive).toHaveBeenLastCalledWith(true); + + await wrapper.setProps({ running: false }); + expect(mocks.setStageActive).toHaveBeenLastCalledWith(false); + + await wrapper.setProps({ running: true }); + wrapper.unmount(); + expect(mocks.setStageActive).toHaveBeenLastCalledWith(false); + }); }); diff --git a/frontend/src/v2/components/Player/PlayerShell.vue b/frontend/src/v2/components/Player/PlayerShell.vue index 0add5949c..2eb0095ba 100644 --- a/frontend/src/v2/components/Player/PlayerShell.vue +++ b/frontend/src/v2/components/Player/PlayerShell.vue @@ -9,6 +9,7 @@ import { useI18n } from "vue-i18n"; import type { DetailedRom, SimpleRom } from "@/stores/roms"; import GameCover from "@/v2/components/shared/GameCover.vue"; import { usePlayerNav } from "@/v2/composables/usePlayerNav"; +import { useStageActive } from "@/v2/composables/useStageActive"; interface Props { /** Full rom once loaded, else the cover-only seed during the morph-in. */ @@ -34,6 +35,9 @@ const { backToRom, backToPlatform } = usePlayerNav( props.romId, () => props.heroRom?.platform_id, ); +// The shell owns the running flag, so it also drives the chrome unmount +// for every player built on it. +useStageActive(() => props.running);