Cookie button stays in the bottom corner of the window; it no longer climbs above the footer

Owner, 2026-12-01: by default the cookie button should go to the bottom of the page, not to the footer.
Until now the button (fixed, a child of <body>) moved up by the visible part of the footer: on a phone with a tall
footer it ended at the top of the screen over the header, on a short page in the middle of it.

- Default: fixed in the bottom corner on every page and scroll position; safe-area inset also on the side.
- Only at the very end of the page it steps just above a link, button or form field it would keep covered
  (`clear`, COOKIE_BUTTON_CLEAR, stepAbove); a transform, no layout shift.
- The placement before: avoid={COOKIE_BUTTON_AVOID}; avoid={false} still means never move; className as before.

Tests: test/cookieButtonPlacement.test.ts; reference e2e on desktop and phone (corner on long and short pages,
no covered control at the page end, no layout shift, keyboard reopen).
Docs: consent.md "Where the cookie button sits", AGENT.md, skills, PROGRAMISTA item 83, changelog draft 1.17.2.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
Radosław Smoliński
2026-12-01 10:49:23 +01:00
co-authored by Claude Fable 5.2
parent fc70a34f3e
commit 1025446a28
15 changed files with 426 additions and 28 deletions
+64
View File
@@ -493,6 +493,70 @@ test('consent: withdrawal — reopen, reject: analytics cookies and listed stora
expect((await consentRecord(context))!.state).toMatchObject({ analytics: false, functional: false, marketing: false })
})
// The "cookie settings" button stays in the bottom corner of the window (1.17.2): it does not climb above the footer.
// At the very end of the page it steps above a link it would keep covered.
for (const device of [
{ name: 'desktop', viewport: { height: 800, width: 1280 } },
{ name: 'phone', viewport: { height: 844, width: 390 } },
]) {
test(`cookie button, ${device.name}: bottom corner on long and short pages, never on a link at the page end, no layout shift`, async ({ browser }) => {
const context = await browser.newContext({ viewport: device.viewport })
const page = await context.newPage()
await page.addInitScript(() => {
const w = window as unknown as { __cls: number }
w.__cls = 0
new PerformanceObserver((list) => {
for (const entry of list.getEntries() as unknown as { hadRecentInput: boolean; value: number }[]) {
if (!entry.hadRecentInput) {w.__cls += entry.value}
}
}).observe({ buffered: true, type: 'layout-shift' })
})
await page.goto('/pl')
await page.locator('[data-ipal="reject"]').click()
const button = page.locator('[data-ipal="cookie-button"]')
const probe = () =>
button.evaluate((b: HTMLElement) => {
const r = b.getBoundingClientRect()
b.style.pointerEvents = 'none'
const covered = [[r.left + 4, r.top + 4], [r.right - 4, r.top + 4], [r.left + 4, r.bottom - 4], [r.right - 4, r.bottom - 4], [r.left + r.width / 2, r.top + r.height / 2]]
.map(([x, y]) => document.elementFromPoint(x, y)?.closest('a, button, input, select, textarea, summary'))
.filter(Boolean)
.map((el) => (el!.textContent ?? '').trim().slice(0, 30))
b.style.pointerEvents = ''
return { covered, gap: Math.round(window.innerHeight - r.bottom), inFooter: !!b.closest('footer'), left: Math.round(r.left), position: getComputedStyle(b).position }
})
for (const path of ['/pl', '/pl/regulamin', '/pl/kontakt']) {
await page.goto(path)
await expect(button).toBeVisible()
const shifts = () => page.evaluate(() => (window as unknown as { __cls: number }).__cls)
await page.waitForTimeout(300)
const before = await shifts()
const height = await page.evaluate(() => document.documentElement.scrollHeight)
for (const y of [0, Math.max(0, (height - device.viewport.height) / 2)]) {
await page.evaluate((to) => window.scrollTo(0, to), y)
await page.waitForTimeout(350)
if (y + device.viewport.height < height - 2) {
// anywhere above the end of the page: exactly in the corner, the footer in view or not
expect(await probe(), `${path} at ${Math.round(y)}`).toMatchObject({ gap: 16, inFooter: false, left: 16, position: 'fixed' })
}
}
await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight))
await page.waitForTimeout(450)
const end = await probe()
expect(end, `${path} at the end`).toMatchObject({ covered: [], inFooter: false, left: 16, position: 'fixed' })
expect(end.gap, `${path}: still at the bottom, not above the footer`).toBeLessThan(120)
expect((await shifts()) - before, `${path}: layout shift while scrolling`).toBeLessThan(0.001)
}
// keyboard: reachable and it reopens the banner
await button.focus()
await expect(button).toBeFocused()
await page.keyboard.press('Enter')
await expect(page.locator('[data-ipal="banner"]')).toBeVisible()
await expect(button).toHaveCount(0)
await context.close()
})
}
test('admin: sign in through 2FA, agency credit, panel link preview', async ({ page, request }) => {
const head = await (await request.get('/admin/login')).text()
expect(head).toMatch(/noindex/)