Skip to content

Make a.add-code-comment click handler an event handler #17737

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web_src/js/features/repo-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ export function initRepoPullRequestReview() {
$(this).closest('.menu').toggle('visible');
});

$('a.add-code-comment').on('click', async function (e) {
$(document).on('click', 'a.add-code-comment', async function (e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add a comment here detailing why it is better to use a document listener here than a local listener, i.e.

// We listen on the document instead of locally as files can be lazy-loaded at a later time
// and the listener would need to be added there as well

Otherwise, this issue might reoccur somewhen.

if ($(e.target).hasClass('btn-add-single')) return; // https://github.com/go-gitea/gitea/issues/4745
e.preventDefault();

Expand Down