Skip to content
Snippets Groups Projects

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

Merged 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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • @mikegreiling when I was testing this, I went to http://localhost:3000/gitlab-org/gitlab-ce#user-content_open-source-software-to-collaborate-on-code and it focused the anchor tag. Can we make it not outline the hidden anchor tag? Screen_Shot_2016-11-22_at_3.22.41_PM

  • @ClemMakesApps yeah, I can do this. However, I don't think many people are going to ever see or use permalinks formatted with the namespace included like you did there, so I'm not sure how common this will be :)

  • I agree, probably very uncommon but wanted to make sure everything is :100:

  • Added 1 commit:

    • b9530852 - prevent anchor tag outline on :focus or :target pseudo-class

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading