Clicking "Add collapsible section" with multiple highlighted lines creates one <details> per line instead of surrounding entire selection
Implementation guide
This issue is correct in that if you select a set of lines and click the "details" toolbar button, then the entire selection should be wrapped in one details block.
Start at https://gitlab.com/gitlab-org/gitlab/blob/master/app/views/shared/blob/_markdown_buttons.html.haml#L40-L43 for where the details-block toolbar button for the plain text editor is captured. That may then lead you to https://gitlab.com/gitlab-org/gitlab/blob/master/app/assets/javascripts/lib/utils/text_markdown.js. Unclear where the actual fix needs to be, but most likely in one of those files.
Summary
Steps to reproduce
- Highlight multiple lines of text in the plain text comment editor
- Click "Add collapsible section"
- Observe that each line is wrapped in a separate
<details>block
Example Project
Any.
What is the current bug behavior?
Each line is wrapped in a separate <details> block, e.g.:
<details><summary>Click to expand</summary>
Foo
</details>
<details><summary>Click to expand</summary>
Bar
</details>
<details><summary>Click to expand</summary>
Baz
</details>
What is the expected correct behavior?
The whole selection should be wrapped in a single <details> block, e.g.:
<details><summary>Click to expand</summary>
Foo
Bar
Baz
</details>
Relevant logs and/or screenshots
simplescreenrecorder-2025-03-05_11.53.21
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)(we will only investigate if the tests are passing)