diff --git a/docs/FRONTEND_ARCHITECTURE.md b/docs/FRONTEND_ARCHITECTURE.md index bbe543773..0ec63a741 100644 --- a/docs/FRONTEND_ARCHITECTURE.md +++ b/docs/FRONTEND_ARCHITECTURE.md @@ -292,8 +292,7 @@ frontend/ │ ├── index.ts # ~825 lines of utilities │ ├── covers.ts # Procedural SVG cover generation │ ├── formData.ts # FormData builder - │ ├── tasks.ts # Task status maps - │ └── indexdb-monitor.ts # IndexedDB change detection + │ └── tasks.ts # Task status maps │ └── __generated__/ # OpenAPI codegen output └── models/ # Generated TypeScript interfaces diff --git a/frontend/src/v2/composables/usePlayerFullscreen/index.test.ts b/frontend/src/v2/composables/usePlayerFullscreen/index.test.ts index 8f565ad8a..67a43d405 100644 --- a/frontend/src/v2/composables/usePlayerFullscreen/index.test.ts +++ b/frontend/src/v2/composables/usePlayerFullscreen/index.test.ts @@ -1,4 +1,4 @@ -import { afterEach, describe, expect, it } from "vitest"; +import { afterEach, describe, expect, it, vi } from "vitest"; import { effectScope, ref, type EffectScope } from "vue"; import { useFullscreenFallback, usePlayerFullscreen } from "./index"; @@ -53,6 +53,26 @@ describe("usePlayerFullscreen", () => { expect(el.hasAttribute("data-fullscreen-fallback")).toBe(true); }); + it("reports a failed exit, which leaves a dialog painted over", async () => { + const el = document.createElement("div"); + document.body.appendChild(el); + const { value } = runInScope(() => + usePlayerFullscreen(ref(el)), + ); + await value.enter(); + const error = vi.spyOn(console, "error").mockImplementation(() => {}); + Object.defineProperty(document, "exitFullscreen", { + value: () => Promise.reject(new Error("denied")), + configurable: true, + writable: true, + }); + + await expect(value.exit()).resolves.toBeUndefined(); + + expect(error).toHaveBeenCalledOnce(); + error.mockRestore(); + }); + it("swallows a denied request instead of rejecting", async () => { Object.defineProperty(Element.prototype, "requestFullscreen", { value: () => Promise.reject(new Error("denied")), diff --git a/frontend/src/v2/composables/usePlayerFullscreen/index.ts b/frontend/src/v2/composables/usePlayerFullscreen/index.ts index 8bc1487b3..aaf0847a5 100644 --- a/frontend/src/v2/composables/usePlayerFullscreen/index.ts +++ b/frontend/src/v2/composables/usePlayerFullscreen/index.ts @@ -22,7 +22,14 @@ export function useFullscreenFallback(): void { // A rejected request is a denial (permissions policy, or no user gesture), // not a fault to report: the stage simply stays windowed. -const swallow = (run: () => Promise) => () => run().catch(() => {}); +const swallowDenial = (run: () => Promise) => () => run().catch(() => {}); + +// A failed exit is not benign: callers exit before opening a body-teleported +// dialog, which would then be painted over by the fullscreen stage. +const reportFailure = (run: () => Promise) => () => + run().catch((error: unknown) => { + console.error("Failed to exit fullscreen", error); + }); /** Fullscreen controls for `target`. */ export function usePlayerFullscreen(target: MaybeElementRef): { @@ -39,8 +46,8 @@ export function usePlayerFullscreen(target: MaybeElementRef): { return { isFullscreen, - enter: swallow(enter), - exit: swallow(exit), - toggle: swallow(toggle), + enter: swallowDenial(enter), + exit: reportFailure(exit), + toggle: swallowDenial(toggle), }; }