Commit 3dcb7a7e authored by Natalia Tepluhina's avatar Natalia Tepluhina Committed by Phil Hughes

Resolve "Ctrl+Enter immediately adds MR comment"

parent 026eefe5
......@@ -150,6 +150,13 @@ export default {
return shouldResolve || shouldToggleState;
},
handleKeySubmit() {
if (this.showBatchCommentsActions) {
this.handleAddToReview();
} else {
this.handleUpdate();
}
},
handleUpdate(shouldResolve) {
const beforeSubmitDiscussionState = this.discussionResolved;
this.isSubmitting = true;
......@@ -223,8 +230,8 @@ export default {
class="note-textarea js-gfm-input js-note-text js-autosize markdown-area js-vue-issue-note-form js-vue-textarea qa-reply-input"
aria-label="Description"
placeholder="Write a comment or drag your files here…"
@keydown.meta.enter="handleUpdate();"
@keydown.ctrl.enter="handleUpdate();"
@keydown.meta.enter="handleKeySubmit();"
@keydown.ctrl.enter="handleKeySubmit();"
@keydown.up="editMyLastNote();"
@keydown.esc="cancelHandler(true);"
></textarea>
......
---
title: Resolve Ctrl+Enter immediately adds MR comment
merge_request: 8932
author:
type: fixed
import Vue from 'vue';
import { createStore } from '~/mr_notes/stores';
import issueNoteForm from '~/notes/components/note_form.vue';
import { keyboardDownEvent } from 'spec/issue_show/helpers';
import { noteableDataMock, discussionMock, notesDataMock } from 'spec/notes/mock_data';
describe('issue_note_form component', () => {
......@@ -35,6 +36,24 @@ describe('issue_note_form component', () => {
it('does not show resolve checkbox', () => {
expect(vm.$el.querySelector('.qa-resolve-review-discussion')).toBe(null);
});
describe('on enter', () => {
it('should add comment when cmd+enter is pressed', () => {
spyOn(vm, 'handleUpdate').and.callThrough();
vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, true));
expect(vm.handleUpdate).toHaveBeenCalled();
});
it('should add comment when ctrl+enter is pressed', () => {
spyOn(vm, 'handleUpdate').and.callThrough();
vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, false, true));
expect(vm.handleUpdate).toHaveBeenCalled();
});
});
});
describe('with batch comments', () => {
......@@ -61,5 +80,23 @@ describe('issue_note_form component', () => {
done();
});
});
describe('on enter', () => {
it('should start review or add to review when cmd+enter is pressed', () => {
spyOn(vm, 'handleAddToReview').and.callThrough();
vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, true));
expect(vm.handleAddToReview).toHaveBeenCalled();
});
it('should start review or add to review when ctrl+enter is pressed', () => {
spyOn(vm, 'handleAddToReview').and.callThrough();
vm.$el.querySelector('textarea').value = 'Foo';
vm.$el.querySelector('textarea').dispatchEvent(keyboardDownEvent(13, false, true));
expect(vm.handleAddToReview).toHaveBeenCalled();
});
});
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment