-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
Docs: Fix Safari scrolling to anchors in iframes. #32312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
This solves https://threejs.org/docs/?q=setviewport#Renderer.setViewport (reported by @WestLangley) Needs more work/investigation. |
|
|
||
| element.scrollIntoView(); | ||
|
|
||
| }, 100 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested a bit more and it seems increasing the timeout from 100 to 200 solves the issue on my macMini.
Given that TSL.html is by far the largest document, the Safari probably needs more time to make the page ready.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we find no other solution, I would like to file a bug at the WebKit bug reporter. I've already searched but found no open bug about scrollIntoView() issues in context of iFrames.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrdoob I've increased the timeout from 100ms to 250 ms which worked on my macMini and an iPad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increasing the time out does not work for me. I tried searching for "translate".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With what devices have you tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
M1 iMac MacOS Tahoe 26.1 Safari 26.1.
To be clear, when searching for "translate", sometimes it works, and in other cases the iframe is blank, and scrolling is necessary to locate the proper position in the file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works for me on all my devices. But it starts failing if I decrease the timeout value.
Just for fun I have removed the element.scrollIntoView() call. In Chrome and Firefox, the navigation is still correct but Safari fails. The page in the iFrame is blank and the content only appears if I scroll up.
So it seems the issue is not related to scrollIntoView(). The iFrame page isn't correctly loaded in the first place and that's maybe why scrollIntoView() fails as well.
Increase timeout.
Related issue: #32302
Description
Fixes an issue where clicking on navigation links in Safari would not scroll to the correct position within the documentation iframe.
The problem occurred because Safari needs additional time to complete iframe layout before scrollIntoView can accurately position the target element. This was only noticeable when navigating via clicks - direct page loads with hash fragments worked fine due to browser's native hash handling.
The fix adds Safari-specific detection and applies a 100ms delay before scrolling, giving Safari time to properly lay out the iframe content.