Skip to content

Conversation

@mark-youssef-bitwarden
Copy link

Problem

When navigating to a (React) page with an anchor ID, sometimes the anchor scroll doesn't work and the scroll position stays at the top of the page.

It seems like the scroll util isn't catching the anchor element in those cases because the React page hasn't fully rendered yet. I noticed there a check for the anchor element in a non-blocking thread using setTimeout, but it's still not quite consistent.

Solution

My attempt instead wraps the anchor check in a double requestAnimationFrame to wait for next render cycle before checking for the anchor element.

@pascalbaljet
Copy link
Member

Is this on the initial page load, or on subsequent requests? There's a fix in v2.2.19 for scrolling to an element on the initial page load.

@pascalbaljet pascalbaljet added the needs more info/work Needs more info from the author or additional work to get merged label Nov 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs more info/work Needs more info from the author or additional work to get merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants