Skip to content

Commit 08b8c0c

Browse files
committed
forget pos remember when having hash
1 parent a8a1d57 commit 08b8c0c

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

web_src/js/features/repo-issue.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,22 +438,24 @@ export async function handleReply($el) {
438438

439439
export function initRepoPullRequestReview() {
440440
if (window.location.hash && window.location.hash.startsWith('#issuecomment-')) {
441+
(history.scrollRestoration != 'manual') && (history.scrollRestoration = 'manual');
441442
const commentDiv = $(window.location.hash);
442-
console.log(commentDiv[0])
443443
if (commentDiv) {
444444
// get the name of the parent id
445445
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);
449446
if (groupID && groupID.startsWith('code-comments-')) {
450447
const id = groupID.slice(14);
448+
const ancestorDiffHeader = commentDiv.closest('.diff-file-box').children('.diff-file-header').eq(0)[0];
451449
$(`#show-outdated-${id}`).addClass('gt-hidden');
452450
$(`#code-comments-${id}`).removeClass('gt-hidden');
453451
$(`#code-preview-${id}`).removeClass('gt-hidden');
454452
$(`#hide-outdated-${id}`).removeClass('gt-hidden');
455-
console.log('scrollIntoView')
456-
commentDiv[0].scrollIntoView();
453+
setFileFolding(ancestorDiffHeader.closest('.file-content'), ancestorDiffHeader.querySelector('.fold-file'), false);
454+
commentDiv[0].scrollIntoView({
455+
behavior: 'auto',
456+
block: 'center',
457+
inline: 'center'
458+
});
457459
}
458460
}
459461
}

0 commit comments

Comments
 (0)