Skip to content

wiki anchors don't work

Summary

Wiki anchor links do not work.

Steps to reproduce

  1. Create a page long enough to need to scroll to get to a title, with multiple headings and a [[_TOC_]] entry
  2. click on some TOC entry that makes the page scroll (that works)
  3. copy the URL in the URL bar
  4. open a new tab
  5. paste the URL
  6. notice how the page doesn't scroll down to the anchor

Example Project

This link should drop down to the "Colonial Internet" anchor, but doesn't: https://gitlab.com/anarcat/test/-/wikis/long-page-no-anchors#colonial-internet

What is the current bug behavior?

The viewport doesn't scroll down in my web browser. Reproducible in:

  • Firefox 91.9.0esr (64-bit) with an empty profile, on Debian 11 bullseye
  • Chromium 101.0.4951.41 (Official Build) built on Debian 11.3, running on Debian 11.3 (64-bit)

What is the expected correct behavior?

The viewport should scroll.

Relevant logs and/or screenshots

This is pretty unremarkable for a screenshot, but you asked for one. :)

screenshot of Firefox rendering the wiki page without scrolling to the right place

Output of checks

This bug happens on GitLab.com

Possible fixes

I'm not sure, but it looks like this happens because the wiki page content is dynamically loaded after the actual page load, and then the browser can't find the anchor at load time. There would probably need to be some javascript that scrolls the viewport after the wiki page actually load.

Future iterations

Alternatively, how about getting rid of some javascript here and just render the page correctly without javascript? Right now if I turn off javascript (with uBlock), the page just renders a blank, which is pretty bad behavior. text-based browsers like w3m also fail to render the page, and i suspect crawlers might have trouble too. Follow up issue to address this is #363122.

Edited by Eric Schurter