Attaching a file by clicking the markdown editor button deletes the character before the cursor
Summary
When using the markdown editor, if you click the Attach a file or image
button without any text selected, the character before your cursor in the text field will be deleted (even if you don't choose a file to attach).
Steps to reproduce
- use any markdown field - issue description, MR description, comment on an issue/MR
- type some text, like
aaaaaab
- click the
Attach a file or image
button - cancel the dialogue or attach a file
- the last character that you typed will be erased:
aaaaaab
=>aaaaaa
Example Project
What is the current bug behavior?
When the Attach a file or image
button is clicked, one character is erased from the text field (regardless of whether a file was attached)
What is the expected correct behavior?
When the Attach a file or image
button is clicked, text should not be erased from the field - it should do nothing if no file was attached or insert the file markdown if a file was attached.
Relevant logs and/or screenshots
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)
Possible fixes
Workaround: select some text or type a sacrificial character before you attach a file
If you can, link to the line of code that might be responsible for the problem.