-
Notifications
You must be signed in to change notification settings - Fork 1
Fix Panel C target reachability and compact power-up tray re-anchoring on fullscreen lifecycle changes #76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -100,6 +100,13 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this._displayLayoutHandler = () => this.syncDisplayLayout(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| window.addEventListener("resize", this._displayLayoutHandler); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| window.addEventListener("orientationchange", this._displayLayoutHandler); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| document.addEventListener("fullscreenchange", this._displayLayoutHandler); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const sharedResizeObserver = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| window.__ensureSharedResizeObserver?.() || window.SharedResizeObserver; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sharedResizeObserver?.subscribe?.(this._displayLayoutHandler, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| immediate: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| source: "worm-powerups-ui", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
101
to
+109
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| window.addEventListener("resize", this._displayLayoutHandler); | |
| window.addEventListener("orientationchange", this._displayLayoutHandler); | |
| document.addEventListener("fullscreenchange", this._displayLayoutHandler); | |
| const sharedResizeObserver = | |
| window.__ensureSharedResizeObserver?.() || window.SharedResizeObserver; | |
| sharedResizeObserver?.subscribe?.(this._displayLayoutHandler, { | |
| immediate: true, | |
| source: "worm-powerups-ui", | |
| }); | |
| } | |
| if (!this._displayLayoutUnsubscribe) { | |
| const sharedResizeObserver = | |
| window.__ensureSharedResizeObserver?.() || window.SharedResizeObserver; | |
| if (sharedResizeObserver?.subscribe) { | |
| const unsubscribe = sharedResizeObserver.subscribe( | |
| this._displayLayoutHandler, | |
| { | |
| immediate: true, | |
| source: "worm-powerups-ui", | |
| }, | |
| ); | |
| this._displayLayoutUnsubscribe = | |
| typeof unsubscribe === "function" ? unsubscribe : null; | |
| } else { | |
| window.addEventListener("resize", this._displayLayoutHandler); | |
| window.addEventListener("orientationchange", this._displayLayoutHandler); | |
| document.addEventListener("fullscreenchange", this._displayLayoutHandler); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,6 +6,8 @@ import { | |||||||||||||||||||||||||||||||
| waitForGameplayInputReady, | ||||||||||||||||||||||||||||||||
| } from "./utils/onboarding-runtime.js"; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| const COMPACT_TRAY_MAX_TOP = 80; | ||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Avoid hard-coding a magic top threshold for the compact tray to reduce layout brittleness. Using a fixed
Suggested change
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| async function pressPowerUp(page, type) { | ||||||||||||||||||||||||||||||||
| await page | ||||||||||||||||||||||||||||||||
| .locator(`[data-testid="powerup-${type}"]`) | ||||||||||||||||||||||||||||||||
|
|
@@ -463,6 +465,49 @@ test.describe("Power-Up Compact Layout", () => { | |||||||||||||||||||||||||||||||
| expect(layout.computedTop).not.toBe("auto"); | ||||||||||||||||||||||||||||||||
| expect(layout.distanceToTop).toBeLessThan(layout.distanceToBottom); | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| test("re-anchors the power-up tray after fullscreen lifecycle changes", async ({ | ||||||||||||||||||||||||||||||||
| page, | ||||||||||||||||||||||||||||||||
| }) => { | ||||||||||||||||||||||||||||||||
| await page.evaluate(() => { | ||||||||||||||||||||||||||||||||
| const display = document.getElementById("power-up-display"); | ||||||||||||||||||||||||||||||||
| if (!display) { | ||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| display.dataset.dragged = "false"; | ||||||||||||||||||||||||||||||||
| display.style.left = "8px"; | ||||||||||||||||||||||||||||||||
| display.style.top = `${Math.round(window.innerHeight * 0.6)}px`; | ||||||||||||||||||||||||||||||||
| document.dispatchEvent(new Event("fullscreenchange")); | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| await expect | ||||||||||||||||||||||||||||||||
| .poll( | ||||||||||||||||||||||||||||||||
| async () => | ||||||||||||||||||||||||||||||||
| page.evaluate((maxTop) => { | ||||||||||||||||||||||||||||||||
| const display = document.getElementById("power-up-display"); | ||||||||||||||||||||||||||||||||
| const panelB = document.getElementById("panel-b"); | ||||||||||||||||||||||||||||||||
| const controls = document.querySelector(".panel-b-controls"); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (!display || !panelB || !controls) { | ||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| const rect = display.getBoundingClientRect(); | ||||||||||||||||||||||||||||||||
| const panelRect = panelB.getBoundingClientRect(); | ||||||||||||||||||||||||||||||||
| const controlsRect = controls.getBoundingClientRect(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||
| rect.left >= panelRect.left && | ||||||||||||||||||||||||||||||||
| rect.right <= panelRect.right && | ||||||||||||||||||||||||||||||||
| rect.bottom <= controlsRect.top && | ||||||||||||||||||||||||||||||||
| rect.top < maxTop | ||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||
| }, COMPACT_TRAY_MAX_TOP), | ||||||||||||||||||||||||||||||||
| { timeout: 5000 }, | ||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||
| .toBe(true); | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| test.describe("Power-Up Portrait Rotation Contract", () => { | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Consider how the new fullscreen listener and resize observer subscription are cleaned up to avoid leaks.
These are long-lived subscriptions. Please ensure the UI’s teardown/dispose path removes the
documentfullscreenchangelistener and unsubscribes from the shared resize observer (if it returns an unsubscribe handle); otherwise repeated teardown/recreate cycles may accumulate handlers.