fix: don't rely on requestAnimationFrame (#34065)

This commit is contained in:
Simon Knott 2024-12-18 11:41:48 +01:00 committed by GitHub
parent c9ae644e5f
commit 443b2a2bbc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View file

@ -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);

View file

@ -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 }) => {