Skip to content

Disable commenting on invalid lines (no identifier or in renamed files)

What does this MR do and why?

Disables the comment button on a line of code if:

  1. The file has no changes other than being moved, which causes an error when trying to save
  2. The line of doesn't have a line_code assigned, which would make commenting impossible

This MR also fixes an existing bug with disabled comment buttons that would change the text color (and thus the color of the icon), but leave the background (since it's disabled), leading to the icon looking like it disappears.

Screenshots or screen recordings

Before (master) After (this branch)
Trying to comment on any line in a file that is only moved and/or renamed comment-on-invalid-lines-moved-file-master comment-on-invalid-lines-moved-file-branch
Trying to comment on a line displayed by GitLab but isn't part of the source file comment-on-invalid-lines-no-newline-master comment-on-invalid-lines-no-newline-branch

How to set up and validate locally

Please use the reproduction steps from the associated issue (rename a file in an MR).

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #239326 (closed)

Edited by Thomas Randolph

Merge request reports