Fix handleLocationHash behavior for MRs and issuables
requested to merge 451601-click-link-to-header-in-rendered-markdown-description-scroll-to-wrong-height into master
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 |
---|---|
MR
Before | After |
---|---|
How to set up and validate locally
For an issue:
- Create an issue (it's likely best to create a new throwaway one for this to ensure the right conditions are met)
- 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.
- 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.
- Save the issue.
- 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
- 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:
- Follow steps 1 through 4 above for an MR description. You can just copy and paste the same text.
- Click on your first H2
- expected: it scrolls to the top of the visible area and is not obscured
- 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