diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2016-12-28 21:30:24 +0000 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-12-28 21:30:24 +0000 |
commit | 170b712f4f141519f3bd395fdaaefc36e3b27f94 (patch) | |
tree | 6abaa9abe1c9f04e91014499248a1ab884186ddb | |
parent | 19e3ab18af273d3d17deabe7e18cd78a3f903644 (diff) | |
parent | 49d288499c554cc0fe3f8a957dee3bb7ea7368f7 (diff) | |
download | gitlab-ce-170b712f4f141519f3bd395fdaaefc36e3b27f94.tar.gz |
Merge branch '24876-page-jumps-to-wrong-position-when-clicking-a-comment-anchor' into 'master'
Fix instances where clicking a comment anchor twice will scroll to the wrong position
Closes #24876
See merge request !8046
-rw-r--r-- | app/assets/javascripts/application.js | 8 | ||||
-rw-r--r-- | changelogs/unreleased/24876-page-jumps-to-wrong-position-when-clicking-a-comment-anchor.yml | 4 |
2 files changed, 12 insertions, 0 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 043c6a11c4f..e43afbb4cc9 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -89,6 +89,14 @@ // Set the default path for all cookies to GitLab's root directory Cookies.defaults.path = gon.relative_url_root || '/'; + // `hashchange` is not triggered when link target is already in window.location + $body.on('click', 'a[href^="#"]', function() { + var href = this.getAttribute('href'); + if (href.substr(1) === gl.utils.getLocationHash()) { + setTimeout(gl.utils.handleLocationHash, 1); + } + }); + // prevent default action for disabled buttons $('.btn').click(function(e) { if ($(this).hasClass('disabled')) { diff --git a/changelogs/unreleased/24876-page-jumps-to-wrong-position-when-clicking-a-comment-anchor.yml b/changelogs/unreleased/24876-page-jumps-to-wrong-position-when-clicking-a-comment-anchor.yml new file mode 100644 index 00000000000..c31c89dc4bc --- /dev/null +++ b/changelogs/unreleased/24876-page-jumps-to-wrong-position-when-clicking-a-comment-anchor.yml @@ -0,0 +1,4 @@ +--- +title: ensure permalinks scroll to correct position on multiple clicks +merge_request: 8046 +author: |