Skip to content

Commit f5ec800

Browse files
committed
scroll to viewed comment
1 parent 0d7cf7b commit f5ec800

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

web_src/js/features/repo-issue.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {initEasyMDEImagePaste} from './comp/ImagePaste.js';
66
import {initCompMarkupContentPreviewTab} from './comp/MarkupContentPreview.js';
77
import {initTooltip, showTemporaryTooltip} from '../modules/tippy.js';
88
import {hideElem, showElem, toggleElem} from '../utils/dom.js';
9+
import {setFileFolding} from './file-fold.js';
910

1011
const {appSubUrl, csrfToken} = window.config;
1112

@@ -438,15 +439,20 @@ export async function handleReply($el) {
438439
export function initRepoPullRequestReview() {
439440
if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) {
440441
const commentDiv = $(window.location.hash);
442+
console.log(commentDiv[0])
441443
if (commentDiv) {
442444
// get the name of the parent id
443445
const groupID = commentDiv.closest('div[id^="code-comments-"]').attr('id');
446+
const ancestorDiffHeader = commentDiv.closest('.diff-file-box').children('.diff-file-header').eq(0)[0];
447+
console.log(ancestorDiffHeader)
448+
setFileFolding(ancestorDiffHeader.closest('.file-content'), ancestorDiffHeader.querySelector('.fold-file'), false);
444449
if (groupID && groupID.startsWith('code-comments-')) {
445450
const id = groupID.slice(14);
446451
$(`#show-outdated-${id}`).addClass('gt-hidden');
447452
$(`#code-comments-${id}`).removeClass('gt-hidden');
448453
$(`#code-preview-${id}`).removeClass('gt-hidden');
449454
$(`#hide-outdated-${id}`).removeClass('gt-hidden');
455+
console.log('scrollIntoView')
450456
commentDiv[0].scrollIntoView();
451457
}
452458
}

0 commit comments

Comments
 (0)