From 443b2a2bbc51b6ea587f93975333e377af2248e2 Mon Sep 17 00:00:00 2001 From: Simon Knott Date: Wed, 18 Dec 2024 11:41:48 +0100 Subject: [PATCH] fix: don't rely on requestAnimationFrame (#34065) --- packages/html-reporter/src/links.tsx | 2 +- tests/playwright-test/reporter-html.spec.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/html-reporter/src/links.tsx b/packages/html-reporter/src/links.tsx index a6ea1e6695..b8db4c0e9e 100644 --- a/packages/html-reporter/src/links.tsx +++ b/packages/html-reporter/src/links.tsx @@ -143,7 +143,7 @@ export function useIsAnchored(id: AnchorID) { export function Anchor({ id, children }: React.PropsWithChildren<{ id: AnchorID }>) { const ref = React.useRef(null); const onAnchorReveal = React.useCallback(() => { - requestAnimationFrame(() => ref.current?.scrollIntoView({ block: 'start', inline: 'start' })); + ref.current?.scrollIntoView({ block: 'start', inline: 'start' }); }, []); useAnchor(id, onAnchorReveal); diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts index 5568455d63..556d12e8a2 100644 --- a/tests/playwright-test/reporter-html.spec.ts +++ b/tests/playwright-test/reporter-html.spec.ts @@ -936,6 +936,9 @@ for (const useIntermediateMergeReport of [true, false] as const) { await expect(attachment).not.toBeInViewport(); await page.getByLabel('attach "foo-2"').getByTitle('link to attachment').click(); await expect(attachment).toBeInViewport(); + + await page.reload(); + await expect(attachment).toBeInViewport(); }); test('should highlight textual diff', async ({ runInlineTest, showReport, page }) => {