diff --git a/src/webview/src/components/CommentForm.vue b/src/webview/src/components/CommentForm.vue index e356cf0b20dc1b68a8236fe058fc1647a6c4f9d8..d35add5a480224233b96dbb807753f34de800750 100644 --- a/src/webview/src/components/CommentForm.vue +++ b/src/webview/src/components/CommentForm.vue @@ -18,6 +18,9 @@ export default { buttonTitle() { return this.isSaving ? 'Saving...' : 'Comment'; }, + canSubmit() { + return !this.isSaving && this.note.length > 0; + }, }, methods: { getNoteType() { @@ -26,6 +29,10 @@ export default { : { type: 'issue', path: 'issues' }; }, addComment() { + if (!this.canSubmit) { + return; + } + const { issuable, note, command } = this; this.isSaving = true; @@ -33,6 +40,11 @@ export default { const noteType = this.getNoteType(); window.vsCodeApi.postMessage({ command, issuable, note, noteType }); }, + handleKeydown({ key, ctrlKey, shiftKey, metaKey, altKey }) { + if (key === 'Enter' && (ctrlKey || metaKey) && !shiftKey && !altKey) { + this.addComment(); + } + }, }, mounted() { window.addEventListener('message', event => { @@ -52,8 +64,8 @@ export default {