Skip to content

Fix handleLocationHash behavior for MRs and issuables

What does this MR do and why?

Corrects handleLocationHash adjustment for links to anchors within rendered markdown in issuable and MR descriptions or comments. Also prevents unnecessary scroll adjustment on page refresh when there is a hash on the window location.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

These screenshots show where a header scrolls to when the link button is clicked:

Issue

Before After
Screenshot_2024-03-22_at_18.18.26 image

MR

Before After
image image

How to set up and validate locally

For an issue:

  1. Create an issue (it's likely best to create a new throwaway one for this to ensure the right conditions are met)
  2. In the issue description, add a few paragraphs of nonsense, then an H2. Make sure that the H2 will be above the fold when you are scrolled to the top of the page while viewing the issue, but it has a few paragraphs above it.
  3. Add some more paragraphs of nonsense, then another H2. Make sure that this H2 will be below the fold when you are scrolled to the top of the page while viewing the issue.
  4. Save the issue.
  5. Scroll to the top of the page (if necessary), then click the link next to your first H2 in the description.
    • expected: scroll up and the entire H2 is visible
  6. Scroll down a bit so that your second H2 header is visible. Click the link icon button to scroll it to the top.
    • expected: it scrolls to the top of the visible area and is not obscured

For an MR:

  1. Follow steps 1 through 4 above for an MR description. You can just copy and paste the same text.
  2. Click on your first H2
    • expected: it scrolls to the top of the visible area and is not obscured
  3. Repeat the same thing for the other H2 further down the page
    • expected: it scrolls to the top of the visible area and is not obscured

Related to #451601 (closed), #425467 (closed)

Edited by Chad Lavimoniere

Merge request reports