summaryrefslogtreecommitdiffstats
path: root/web_src/js/index.js
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-10-31 04:35:35 +0000
committerGitHub <noreply@github.com>2020-10-31 00:35:35 -0400
commitffc8ce7baef0715bdc2d04cfc1e18379426a1e89 (patch)
treeeb6e338b27f31bb60ed1a3d1bcf7edf3df30da51 /web_src/js/index.js
parent6c323678d0a0872825e90d1339db802ebce3fb76 (diff)
downloadgitea-ffc8ce7baef0715bdc2d04cfc1e18379426a1e89.tar.gz
gitea-ffc8ce7baef0715bdc2d04cfc1e18379426a1e89.zip
Fix scrolling to resolved comment anchors (#13343)
* Fix scrolling to resolved comment anchors As described on discord, when the window.location.hash refers to a resolved comment then the scroll to functionality does not work. This PR fixes this. Signed-off-by: Andrew Thornton <art27@cantab.net> * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'web_src/js/index.js')
-rw-r--r--web_src/js/index.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index cdabffe04d..7c56703144 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -1172,6 +1172,22 @@ async function initRepository() {
}
function initPullRequestReview() {
+ if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) {
+ const commentDiv = $(window.location.hash);
+ if (commentDiv) {
+ // get the name of the parent id
+ const groupID = commentDiv.closest('div[id^="code-comments-"]').attr('id');
+ if (groupID && groupID.startsWith('code-comments-')) {
+ const id = groupID.substr(14);
+ $(`#show-outdated-${id}`).addClass('hide');
+ $(`#code-comments-${id}`).removeClass('hide');
+ $(`#code-preview-${id}`).removeClass('hide');
+ $(`#hide-outdated-${id}`).removeClass('hide');
+ $(window).scrollTop(commentDiv.offset().top);
+ }
+ }
+ }
+
$('.show-outdated').on('click', function (e) {
e.preventDefault();
const id = $(this).data('comment');