diff --git a/packages/starpod/src/components/media/Island.tsx b/packages/starpod/src/components/media/Island.tsx index dbf41b3..e306c45 100644 --- a/packages/starpod/src/components/media/Island.tsx +++ b/packages/starpod/src/components/media/Island.tsx @@ -313,6 +313,11 @@ export function go(home: IslandHome) { island.dataset.state = to; island.setAttribute('data-⚓️-to', `--home-${to}`); document.documentElement.dataset.island = to; + // The card keeps its scroll through the homes that clip it, so one left + // scrolled down would open with its close and grabber out of sight. + if (to === 'card') { + island.scrollTop = 0; + } if (station) { const end = station.getBoundingClientRect(); island.style.width = `${end.width}px`; diff --git a/tests/e2e/player-phone.spec.ts b/tests/e2e/player-phone.spec.ts index a21f549..df3551b 100644 --- a/tests/e2e/player-phone.spec.ts +++ b/tests/e2e/player-phone.spec.ts @@ -78,6 +78,25 @@ test('the card closes from its visible close, and from a swipe down its top', as await expect(island).toHaveAttribute('data-state', 'dock'); }); +test('the card opens at its top, however far down it was left', async ({ page }) => { + await open(page, VIDEO_EPISODE); + await play(page); + const island = page.locator('#player'); + await island.locator('.island-name').click(); + await expect(island).not.toHaveAttribute('data-moving'); + await page.mouse.move(200, 400); + await page.mouse.wheel(0, 300); + await expect.poll(() => island.evaluate((card) => card.scrollTop)).toBeGreaterThan(0); + await page.keyboard.press('Escape'); + await expect(island).toHaveAttribute('data-state', 'dock'); + await expect(island).not.toHaveAttribute('data-moving'); + await island.locator('.island-name').click(); + await expect(island).toHaveAttribute('data-state', 'card'); + await expect(island).not.toHaveAttribute('data-moving'); + expect(await island.evaluate((card) => card.scrollTop)).toBe(0); + await expect(page.getByRole('button', { name: 'Close the now-playing card', exact: true })).toBeInViewport({ ratio: 1 }); +}); + test("a queued episode's remove shows on a touch screen, off its cover", async ({ page }) => { await open(page, VIDEO_EPISODE); await play(page);