Skip to content

Fix JavaScript error when clicking on the comment button on a diff line that has a comment already

What does this MR do?

This MR fixes a JavaScript error that occurs when you click on the comment button on a diff line that already has a comment. Also filters on visible to prevent adding a new comment box after one is already opened.

Why was this MR needed?

To reproduce:

  1. Go to https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/368#note_1340026
  2. Click on "Changes". Scroll down to you see the existing comment.
  3. Attempt to comment on line 1 by highlighting over the line and clicking on the comment bubble.
  4. View the JavaScript console. You should see:
Uncaught TypeError: Cannot read property 'target' of undefined

The issue is that the method expects to get a click event for the button, but no parameters are provided to it in the case when a comment already exists.

Merge request reports