-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
Make a.add-code-comment click handler an event handler #17737
Make a.add-code-comment click handler an event handler #17737
Conversation
Instead of directly attaching the add-code-comment on click handler to the a.add-code-comment elements - make this an event handler on the document instead. Fix go-gitea#17736 Signed-off-by: Andrew Thornton <art27@cantab.net>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validated.
There's one more related thing: when you click a direct link to such a comment (e.g. http://localhost:3000/jpraet/test/pulls/33/files#issuecomment-451) that was added on a file loaded with "Show More", that doesn't work because only the first x files are loaded.
Codecov Report
@@ Coverage Diff @@
## main #17737 +/- ##
=======================================
Coverage ? 45.52%
=======================================
Files ? 807
Lines ? 89791
Branches ? 0
=======================================
Hits ? 40880
Misses ? 42373
Partials ? 6538 Continue to review full report at Codecov.
|
@@ -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) { |
There was a problem hiding this comment.
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.
Instead of directly attaching the add-code-comment on click handler to the a.add-code-comment elements - make this an event handler on the document instead. Fix go-gitea#17736 Signed-off-by: Andrew Thornton <art27@cantab.net>
Instead of directly attaching the add-code-comment on click handler to
the a.add-code-comment elements - make this an event handler on the
document instead.
Fix #17736
Signed-off-by: Andrew Thornton art27@cantab.net