Commit 2f301913 authored by Samantha Ming's avatar Samantha Ming

Prevent autosave when reply comment via cmd+enter

Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/216631

When a user reply to a comment  using cmd + enter
and trigger another reply, the previous comment reappears.
In this commit, we fix this problem by prevent an autosave when user
reply to a comment using cmd + enter .
So when the user trigger another reply, it will be a clean slate.
parent 0d2fd48e
...@@ -101,6 +101,7 @@ export default { ...@@ -101,6 +101,7 @@ export default {
isResolving: this.resolveDiscussion, isResolving: this.resolveDiscussion,
isUnresolving: !this.resolveDiscussion, isUnresolving: !this.resolveDiscussion,
resolveAsThread: true, resolveAsThread: true,
isSubmittingWithKeydown: false,
}; };
}, },
computed: { computed: {
...@@ -241,6 +242,10 @@ export default { ...@@ -241,6 +242,10 @@ export default {
this.$emit('cancelForm', shouldConfirm, this.noteBody !== this.updatedNoteBody); this.$emit('cancelForm', shouldConfirm, this.noteBody !== this.updatedNoteBody);
}, },
onInput() { onInput() {
if (this.isSubmittingWithKeydown) {
return;
}
if (this.autosaveKey) { if (this.autosaveKey) {
const { autosaveKey, updatedNoteBody: text } = this; const { autosaveKey, updatedNoteBody: text } = this;
updateDraft(autosaveKey, text); updateDraft(autosaveKey, text);
...@@ -250,6 +255,7 @@ export default { ...@@ -250,6 +255,7 @@ export default {
if (this.showBatchCommentsActions) { if (this.showBatchCommentsActions) {
this.handleAddToReview(); this.handleAddToReview();
} else { } else {
this.isSubmittingWithKeydown = true;
this.handleUpdate(); this.handleUpdate();
} }
}, },
......
---
title: Prevent autosave when reply comment via cmd+enter
merge_request: 35716
author:
type: fixed
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