diff options
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 2 | ||||
-rw-r--r-- | changelogs/unreleased/40373-fix-issue-note-submit-disabled-on-paste.yml | 6 | ||||
-rw-r--r-- | spec/features/issues/notes_on_issues_spec.rb | 28 |
3 files changed, 35 insertions, 1 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 195e2ca6a78..116b5364fb4 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -190,7 +190,7 @@ export const insertText = (target, text) => { target.selectionStart = target.selectionEnd = selectionStart + insertedText.length; // Trigger autosave - $(target).trigger('input'); + target.dispatchEvent(new Event('input')); // Trigger autosize const event = document.createEvent('Event'); diff --git a/changelogs/unreleased/40373-fix-issue-note-submit-disabled-on-paste.yml b/changelogs/unreleased/40373-fix-issue-note-submit-disabled-on-paste.yml new file mode 100644 index 00000000000..e683e60397e --- /dev/null +++ b/changelogs/unreleased/40373-fix-issue-note-submit-disabled-on-paste.yml @@ -0,0 +1,6 @@ +--- +title: Fix Issue comment submit button being disabled when pasting content from another + GFM note +merge_request: 15530 +author: +type: fixed diff --git a/spec/features/issues/notes_on_issues_spec.rb b/spec/features/issues/notes_on_issues_spec.rb index 05c93a19253..fbe260a017e 100644 --- a/spec/features/issues/notes_on_issues_spec.rb +++ b/spec/features/issues/notes_on_issues_spec.rb @@ -74,4 +74,32 @@ describe 'Create notes on issues', :js do let(:mention) { create(:merge_request, source_project: project) } end end + + describe 'copy GFM note and paste into new comment textarea' do + let(:project) { create(:project, :public) } + let(:note_text) { 'I **got** this!' } + let(:issue) { create(:issue, project: project) } + + before do + project.team << [user, :developer] + sign_in(user) + create(:note, noteable: issue, project: project, note: note_text) + visit project_issue_path(project, issue) + wait_for_requests + end + + it 'can submit comment' do + select_element('.note-text') + # Copy, [:control, 'c'] and [:command, 'c'] don't work + find('body').native.send_keys [:control, :insert] + + find('.js-main-target-form .js-vue-comment-form').click + # Paste, [:control, 'v'] and [:command, 'v'] don't work + find('body').native.send_keys [:shift, :insert] + + expect(find('.js-main-target-form .js-vue-comment-form').value).to include(note_text) + expect(page).to have_css('.js-comment-button') + expect(page).not_to have_css('.js-comment-button[disabled]') + end + end end |