Expand a collapsed diff file when adding a file comment

What does this MR do and why?

In Rapid Diffs, the Comment on this file button mounts the file-level comment form directly, without first expanding the file. When the file is collapsed, the form is added inside the hidden file body, so clicking the button produces no visible change — the user sees nothing happen and keeps clicking with no feedback.

The fix makes the fileComment click handler expand the file first when it's collapsed: if data-collapsed === 'true' on the diff element, it triggers EXPAND_FILE before adding the new file-discussion form. This matches the behaviour legacy diffs already have, so the form is mounted into a visible body and is immediately usable. Files that are already expanded are unaffected (the expand step is skipped).

Changelog: fixed

Before: clicking Comment on this file on a collapsed file in Rapid Diffs does nothing visible — the form mounts inside the still-collapsed body.

After: clicking the button expands the file and the comment form appears, ready to type in.

(Attaching a before/after screen recording of commenting on a collapsed file.)

How to set up and validate locally

  1. Run the adapter spec:

The added case mounts a collapsed file, clicks Comment on this file, and asserts the file expands (data-collapsed cleared and the [data-file-body] <details> open).

  1. In GDK with Rapid Diffs enabled, open a merge request's Changes tab, collapse a file, then click Comment on this file on that collapsed file. Confirm the file expands and the file-level comment form is shown and focused. Repeat on an already-expanded file to confirm it still just adds the form without any regression.

MR acceptance checklist

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

Edited by Jeston Singh

Merge request reports

Loading
Loading