aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2023-03-18 17:48:13 -0400
committerGitHub <noreply@github.com>2023-03-18 16:48:13 -0500
commit1a97a84023febdb111c4c6fe3a42216068635d7b (patch)
tree40dfe3613508077df6242138a45ce2373debe55c
parent420d015b76a49e1018c3f1b73ce3b9f72d86f78c (diff)
downloadgitea-1a97a84023febdb111c4c6fe3a42216068635d7b.tar.gz
gitea-1a97a84023febdb111c4c6fe3a42216068635d7b.zip
Fix JS error on compare page (#23551) (#23566)
Backport #23551 by @silverwind Fix regression from https://github.com/go-gitea/gitea/pull/23271. This code apparently runs on the compare page where there is no review button so check for existance of both button and content. <img width="1226" alt="Screenshot 2023-03-17 at 21 42 47" src="https://user-images.githubusercontent.com/115237/226040001-ec097edd-d926-4c80-9962-526f9b7eff19.png"> Fixes #23562 Co-authored-by: silverwind <me@silverwind.io>
-rw-r--r--web_src/js/features/repo-issue.js28
1 files changed, 15 insertions, 13 deletions
diff --git a/web_src/js/features/repo-issue.js b/web_src/js/features/repo-issue.js
index a110b82c5c..52f777b6a0 100644
--- a/web_src/js/features/repo-issue.js
+++ b/web_src/js/features/repo-issue.js
@@ -515,20 +515,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