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

Documentation links with fragments do not scroll in Chrome #356

Open
akshaydewan opened this issue Aug 26, 2019 · 6 comments
Open

Documentation links with fragments do not scroll in Chrome #356

akshaydewan opened this issue Aug 26, 2019 · 6 comments

Comments

@akshaydewan
Copy link
Contributor

akshaydewan commented Aug 26, 2019

Browser: Google Chrome Version 76.0.3809.100 (Official Build) (64-bit)
OS: MacOS 10.14.6

Steps to reproduce:
Open a link to the documentation containing a fragment, such as this in Chrome

Expected: The page should scroll to Step 2: Material

Actual: The page doesn't scroll to the right section, stays on top of the page

(Works as expected on Firefox)

@ketan
Copy link
Member

ketan commented Aug 26, 2019 via email

@arvindsv
Copy link
Member

On Firefox at least, it seems to be related to the GDPR banner. For some reason, when the GDPR banner is added, the page stops being "split into two" (menu part and content part). So, when it tries to scroll the menu part of the page, it ends up scrolling the whole page.

You can see this behavior more clearly in a page such as: https://docs.gocd.org/19.8.0/configuration/managing_artifacts_and_reports.html#publishing-tests

On a pristine Chrome, it seems to work only the first time it is opened. Then, refreshing the page or even re-entering the URL does not switch to the right section, as @akshaydewan pointed out. :(

PS: Did one or both of you add the "Temporary Containers" add-on to Firefox recently? That causes the GDPR cookie to not exist (new container) and so you might be seeing it happen more often than usual.

@arvindsv
Copy link
Member

arvindsv commented Aug 26, 2019

Has Chrome changed the behavior of how it responds to fragments in URLs?

  1. Go to: https://www.lipsum.com/#Lipsum-Unit5
  2. It'll go to a specific part of the page.
  3. Scroll up to the top.
  4. Refresh. It doesn't move.
  5. Press Enter in the URL bar. It doesn't move.

For Step 4 and 5, Firefox does the right thing.

Edit: Maybe it's a bug related to "Enable Text Fragment Anchor".

@akshaydewan
Copy link
Contributor Author

I can confirm that https://www.lipsum.com/#Lipsum-Unit5 also isn't working as expected in Chrome. From this , looks like a deliberate change in behaviour.

(I haven't installed the Temporary Containers extension in FF. Didn't see the GDPR banner and was working fine. Tried a Private window, and the GDPR banner causes issues like you mentioned).

@arvindsv
Copy link
Member

Something like putting the GDPR banner only in the page content part, rather than in the body and fixing the CSS will probably do the trick on FF:

diff --git a/static/javascripts/_common-to-all-pages.js b/static/javascripts/_common-to-all-pages.js
index 2470decd6..a61b724a4 100644
--- a/static/javascripts/_common-to-all-pages.js
+++ b/static/javascripts/_common-to-all-pages.js
@@ -20,7 +20,8 @@
         document.body.removeChild(banner);
       }
 
-      document.body.insertBefore(banner, document.body.firstChild);
+      const insertLocation = document.getElementsByClassName("book-page")[0];
+      insertLocation.insertBefore(banner, insertLocation.firstChild);
     }
   }

Maybe @veerababukona has some ideas?

@arvindsv
Copy link
Member

Or, @marques-work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants