Skip to content
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

Merged

Conversation

zeripath
Copy link
Contributor

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

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>
@zeripath zeripath added type/bug skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. labels Nov 20, 2021
@zeripath zeripath added this to the 1.16.0 milestone Nov 20, 2021
Copy link
Member

@jpraet jpraet left a 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.

@GiteaBot GiteaBot added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Nov 20, 2021
@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@013fb73). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 013fb73...f8462d5. Read the comment docs.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 20, 2021
@lunny lunny merged commit 0d69e64 into go-gitea:main Nov 20, 2021
@zeripath zeripath deleted the fix-17736-make-add-code-comment-an-event-handler branch November 20, 2021 12:45
@@ -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.

Chianina pushed a commit to Chianina/gitea that referenced this pull request Mar 28, 2022
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>
@go-gitea go-gitea locked and limited conversation to collaborators Apr 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot add code comment on file loaded with "Show More"
6 participants