The reply shortcut can add any text of the page to the "comment" text area
Summary
On a Merge Request or issue page, the r
key enables to quickly select some text to quote it and add it to the "Reply" field of the Merge Request.
This is very useful to reply to someone, however currently one can add any text of the page. Try it here! Select some text from the side menu, then type r
and look at the "reply" field in this issue. I believe this is not the expected behaviour, and we should restrict the shortcut range to text from one message.
This can also be done on the "Changes" section of a Merge Request, leading to addition of text on an invisible textarea. The shortcut should not work when the textarea is hidden.
Steps to reproduce
- Open a issue
- Select some random text from the page (side menu, top bar,...) and press "R"
- Some text appears in the "Reply" box, even if completely unrelated to the current issue.
Example Project
Any issue on gitlab.com
What is the current bug behavior?
One can paste any text from the page to the reply box with the "quote" shortcut
What is the expected correct behavior?
The quote shortcut should only work for messages of the discussion and when the reply box is visible.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com and on any up-to-date Gitlab instance
Results of GitLab environment info
This bug also happens on a freshly installed Gitlab Development Kit
Possible fixes
Thanks to the Selection API, get the parent node of the selected text and make sure it's an issue text.
Potentially related to https://gitlab.com/gitlab-org/gitlab-ce/issues/2598