Skip to content

Commit

Permalink
fix: don't rely on requestAnimationFrame (#34065)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt authored Dec 18, 2024
1 parent c9ae644 commit 443b2a2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/html-reporter/src/links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export function useIsAnchored(id: AnchorID) {
export function Anchor({ id, children }: React.PropsWithChildren<{ id: AnchorID }>) {
const ref = React.useRef<HTMLDivElement>(null);
const onAnchorReveal = React.useCallback(() => {
requestAnimationFrame(() => ref.current?.scrollIntoView({ block: 'start', inline: 'start' }));
ref.current?.scrollIntoView({ block: 'start', inline: 'start' });
}, []);
useAnchor(id, onAnchorReveal);

Expand Down
3 changes: 3 additions & 0 deletions tests/playwright-test/reporter-html.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down

0 comments on commit 443b2a2

Please sign in to comment.