From 0a62fa8f81c4dfb87e12a9eb96e61c0d08943cee Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 13 Apr 2024 17:17:15 +0200 Subject: [PATCH 1/2] Fix JS error when opening to expanded code comment --- web_src/js/features/repo-issue.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js index 0d326aae581fd..9c06eff672038 100644 --- a/web_src/js/features/repo-issue.js +++ b/web_src/js/features/repo-issue.js @@ -449,12 +449,12 @@ export function initRepoPullRequestReview() { offset += $('.diff-detail-box').outerHeight() + $(diffHeader).outerHeight(); } - document.getElementById(`show-outdated-${id}`).classList.add('tw-hidden'); - document.getElementById(`code-comments-${id}`).classList.remove('tw-hidden'); - document.getElementById(`code-preview-${id}`).classList.remove('tw-hidden'); - document.getElementById(`hide-outdated-${id}`).classList.remove('tw-hidden'); + document.getElementById(`show-outdated-${id}`)?.classList.add('tw-hidden'); + document.getElementById(`code-comments-${id}`)?.classList.remove('tw-hidden'); + document.getElementById(`code-preview-${id}`)?.classList.remove('tw-hidden'); + document.getElementById(`hide-outdated-${id}`)?.classList.remove('tw-hidden'); // if the comment box is folded, expand it - if (ancestorDiffBox.getAttribute('data-folded') === 'true') { + if (ancestorDiffBox?.getAttribute('data-folded') === 'true') { setFileFolding(ancestorDiffBox, ancestorDiffBox.querySelector('.fold-file'), false); } From bf6362993ee0eb1a5fb2efd0ccf9971c285b0f7d Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 13 Apr 2024 17:29:26 +0200 Subject: [PATCH 2/2] Update web_src/js/features/repo-issue.js Co-authored-by: wxiaoguang --- web_src/js/features/repo-issue.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js index 9c06eff672038..2b2eed58bbfb3 100644 --- a/web_src/js/features/repo-issue.js +++ b/web_src/js/features/repo-issue.js @@ -449,10 +449,8 @@ export function initRepoPullRequestReview() { offset += $('.diff-detail-box').outerHeight() + $(diffHeader).outerHeight(); } - document.getElementById(`show-outdated-${id}`)?.classList.add('tw-hidden'); - document.getElementById(`code-comments-${id}`)?.classList.remove('tw-hidden'); - document.getElementById(`code-preview-${id}`)?.classList.remove('tw-hidden'); - document.getElementById(`hide-outdated-${id}`)?.classList.remove('tw-hidden'); + hideElem(`#show-outdated-${id}`); + showElem(`#code-comments-${id}, #code-preview-${id}, #hide-outdated-${id}`); // if the comment box is folded, expand it if (ancestorDiffBox?.getAttribute('data-folded') === 'true') { setFileFolding(ancestorDiffBox, ancestorDiffBox.querySelector('.fold-file'), false);