[go: up one dir, main page]

Skip to content

Selecting pending comments does not work for commit-by-commit reviews

Summary

When you review MRs as a single commit at the time, and you draft a comment, the preview does not jump to the correct commit.

Steps to reproduce

  1. Open an MR with multiple commits
  2. Go to the commits tab
  3. Select a commit
  4. Add a draft comment on a line on that commit
  5. Use one of the buttons Prev or Next on the top to go to a different commit
  6. Use the "Pending comments" drop down and click on the draft you've created

What is the current bug behavior?

Nothing.

What is the expected correct behavior?

The page for that commit should be browsed to and the draft comment should be shown and highlighted.

Possible fixes

The endpoint https://gitlab.example.com/<group>/<project>/-/merge_requests/<iid>/drafts gives position data:

    "position": {
      "base_sha": "c10c4110ad2be58737d857f63824f3dd6aafd285",
      "start_sha": "c10c4110ad2be58737d857f63824f3dd6aafd285",
      "head_sha": "2b5ef814763026bd555737a4d96146c3b85e5468",
      ...
    }

I've noticed when the comment is made on a single commit, the base_sha and head_sha are equal and the comment is made on head_sha. The browser should navigate to https://gitlab.example.com/<group>/<project>/-/merge_requests/<iid>/diffs?commit_id=<head_sha> before attempting to scrollToDraft. See https://gitlab.com/gitlab-org/gitlab/-/blob/ebc34272fafe983112bfdd1f2c097e08a2880e21/app/assets/javascripts/batch_comments/components/preview_dropdown.vue#L23-28