Skip to content
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

[Bug] Randomly failed to scroll to anchor when opening docfx site's anchor link #9150

Closed
filzrev opened this issue Aug 30, 2023 · 5 comments · Fixed by #9251 or #9321
Closed

[Bug] Randomly failed to scroll to anchor when opening docfx site's anchor link #9150

filzrev opened this issue Aug 30, 2023 · 5 comments · Fixed by #9251 or #9321
Labels
bug A bug to fix template The stock site template
Milestone

Comments

@filzrev
Copy link
Contributor

filzrev commented Aug 30, 2023

Describe the bug
When opening docfx site anchor link.
Browser failed scroll to anchor randomly.

To Reproduce
Steps to reproduce the behavior:

  1. Open anchor link by browser (https://dotnet.github.io/docfx/docs/markdown.html?tabs=linux%2Cdotnet#code-snippet)
  2. Sometimes scroll don't works or indicate wrong place.

Another example link without tab content/images. (https://dotnet.github.io/docfx/docs/dotnet-api-docs.html#filter-by-type)
It's scroll to Filter by UID randomly.

Expected behavior
Always scrolled to specified anchor.

Context (please complete the following information):

  • Browser: chrome, edge
  • Template: default, modern

Additional context
This issue might be related to browser's event timing.
https://www.bryanbraun.com/anchorjs/#dont-run-it-too-late.

@filzrev filzrev added bug A bug to fix template The stock site template labels Aug 30, 2023
@filzrev filzrev changed the title [Bug] Anchor link is failed [Bug] Randomly failed to scroll to anchor when opening docfx site's anchor link Aug 30, 2023
@yufeih yufeih added this to the Backlog milestone Aug 31, 2023
@shibaev
Copy link

shibaev commented Sep 24, 2023

It seems related to the script that scrolls TOC to the active node. For modern template, it is the scrollIntoView call in toc.ts.

@shibaev
Copy link

shibaev commented Sep 27, 2023

This comment describes problems with scrollIntoView implementation in Chromium and possible workarounds.

@shibaev
Copy link

shibaev commented Sep 28, 2023

Does the fix cover the situation when scroll to anchor works before scrolling TOC to an active element? Currently, I see two types of problem in Chrome:

  1. TOC scrolling runs before the scrolling to anchor. In that case, TOC is properly scrolled but anchor is not reached.
  2. TOC scrolling runs after the scrolling to anchor. In that case, anchor is properly reached but the TOC is not scrolled to an active element.

It looks like the fix may only address the first case.

I also tested the fix on our version of DocFX-based documentation and both issues from cases 1-2 are still there.

@filzrev
Copy link
Contributor Author

filzrev commented Oct 28, 2023

It seems scrolling problems are still existing on latest docfx site.

Urls for tests

Behaviors when click anchor links

  • Successfully scrolled into anchor link.
  • Not scrolled at all
  • Scrolled to wrong position before anchor link.

@shibaev
Copy link

shibaev commented Dec 7, 2023

Agree with @filzrev. The scroll issue still happens. For example, https://dotnet.github.io/docfx/tutorial/advanced_support_hyperlink.html#prepare is often loaded like this (pay attention on TOC scrolling):
image

The expected result should look like:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug to fix template The stock site template
Projects
None yet
3 participants