]> source.dussan.org Git - gitea.git/commitdiff
Fix JS error when opening to expanded code comment (#30463)
authorsilverwind <me@silverwind.io>
Sun, 14 Apr 2024 07:16:03 +0000 (09:16 +0200)
committerGitHub <noreply@github.com>
Sun, 14 Apr 2024 07:16:03 +0000 (15:16 +0800)
Fix regression from
https://github.com/go-gitea/gitea/commit/e0b018706fa7703ef1759d9a75a1399383715808
where opening to a code comment via hash link would give this error:

<img width="1247" alt="image"
src="https://github.com/go-gitea/gitea/assets/115237/f9aaeded-8492-4416-9a73-afa0c56220a7">

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
web_src/js/features/repo-issue.js

index 0d326aae581fde842a31834664d95d9b23bbc080..2b2eed58bbfb3470f38794c6b0cda0298d2a3ae1 100644 (file)
@@ -449,12 +449,10 @@ 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') {
+        if (ancestorDiffBox?.getAttribute('data-folded') === 'true') {
           setFileFolding(ancestorDiffBox, ancestorDiffBox.querySelector('.fold-file'), false);
         }