Skip to content

Commit

Permalink
Fix JS error on compare page (go-gitea#23551)
Browse files Browse the repository at this point in the history
Fix regression from go-gitea#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 go-gitea#23562
  • Loading branch information
silverwind authored and GiteaBot committed Mar 18, 2023
1 parent 420d015 commit 2482db9
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions web_src/js/features/repo-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2482db9

Please sign in to comment.