From 53b609e3361d321a60946376971d6a3c46d4ddb9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 18 Mar 2023 22:08:38 +0100 Subject: [PATCH] Fix JS error on compare page (#23551) Fix regression from #23271. This code apparently runs on the compare page where there is no review button so check for existance of both button and content. Screenshot 2023-03-17 at 21 42 47 Fixes #23562 --- web_src/js/features/repo-issue.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js index f12b10efc..e49b1b272 100644 --- a/web_src/js/features/repo-issue.js +++ b/web_src/js/features/repo-issue.js @@ -516,20 +516,22 @@ export function initRepoPullRequestReview() { const $panel = $reviewBtn.parent().find('.review-box-panel'); const $closeBtn = $panel.find('.close'); - const tippy = createTippy($reviewBtn[0], { - content: $panel[0], - placement: 'bottom', - trigger: 'click', - role: 'menu', - maxWidth: 'none', - interactive: true, - hideOnClick: true, - }); + if ($reviewBtn.length && $panel.length) { + const tippy = createTippy($reviewBtn[0], { + content: $panel[0], + placement: 'bottom', + trigger: 'click', + role: 'menu', + maxWidth: 'none', + interactive: true, + hideOnClick: true, + }); - $closeBtn.on('click', (e) => { - e.preventDefault(); - tippy.hide(); - }); + $closeBtn.on('click', (e) => { + e.preventDefault(); + tippy.hide(); + }); + } $(document).on('click', 'a.add-code-comment', async function (e) { if ($(e.target).hasClass('btn-add-single')) return; // https://github.com/go-gitea/gitea/issues/4745