Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2020-07-04 15:08:58 +00:00
parent 780b5d4c64
commit 90dd41b500
3 changed files with 29 additions and 0 deletions

View File

@ -101,6 +101,7 @@ export default {
isResolving: this.resolveDiscussion,
isUnresolving: !this.resolveDiscussion,
resolveAsThread: true,
isSubmittingWithKeydown: false,
};
},
computed: {
@ -241,6 +242,10 @@ export default {
this.$emit('cancelForm', shouldConfirm, this.noteBody !== this.updatedNoteBody);
},
onInput() {
if (this.isSubmittingWithKeydown) {
return;
}
if (this.autosaveKey) {
const { autosaveKey, updatedNoteBody: text } = this;
updateDraft(autosaveKey, text);
@ -250,6 +255,7 @@ export default {
if (this.showBatchCommentsActions) {
this.handleAddToReview();
} else {
this.isSubmittingWithKeydown = true;
this.handleUpdate();
}
},

View File

@ -0,0 +1,5 @@
---
title: Prevent autosave when reply comment via cmd+enter
merge_request: 35716
author:
type: fixed

View File

@ -245,6 +245,24 @@ describe('issue_note_form component', () => {
expect(updateDraft).toHaveBeenCalledWith(dummyAutosaveKey, dummyContent);
});
it('does not save draft when ctrl+enter is pressed', () => {
const options = {
noteBody: '',
autosaveKey: dummyAutosaveKey,
};
props = { ...props, ...options };
wrapper = createComponentWrapper();
wrapper.setData({ isSubmittingWithKeydown: true });
const textarea = wrapper.find('textarea');
textarea.setValue('some content');
textarea.trigger('keydown.enter', { metaKey: true });
expect(updateDraft).not.toHaveBeenCalled();
});
});
describe('with batch comments', () => {