Skip to content

Resolve "User-generated permalink IDs collide with GitLab interface"

username-removed-636429 requested to merge 22781-user-generated-permalinks into master

What does this MR do?

Prevents ID values automatically generated by headers in GitLab Flavored Markdown from colliding with IDs used elsewhere in the GitLab interface. This can cause confusion when, for instance, a selector looks for a merge request tab with id="pipelines" and there is a header with the same ID earlier in the DOM.

How this works:

  • All header IDs generated with GitLab Flavored Markdown are namespaced with id="user-content_foo"
  • All anchor links which point to these IDs continue to use the non-namespaced hash <a href="#foo">...</a>
  • When a page is loaded or when the hashchange event is triggered, javascript will automatically search for #user-content_foo if #foo cannot be found, and scroll to that position instead.

Before

2016-11-21-13.00.28

After:

2016-11-21-13.12.45
2016-11-21-13.03.00

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

Closes #22781 (closed)

See also prior attempts to address this issue: #3908 (closed), !2023 (merged), !2024 (merged)

Merge request reports