Skip to content

Commit

Permalink
Merge pull request #613 from kamaljohnson/shortcut-key-to-close-reply…
Browse files Browse the repository at this point in the history
…-box

feat: add shortcut key (esc) to close reply box
  • Loading branch information
kamaljohnson authored Aug 9, 2022
2 parents 471deca + 7802dff commit c7331ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
7 changes: 5 additions & 2 deletions desk/src/pages/desk/Ticket.vue
Original file line number Diff line number Diff line change
Expand Up @@ -320,14 +320,17 @@ export default {
delay(1000).then(() => this.scrollConversationsToBottom = false)
},
handleShortcuts(e) {
if ((e.metaKey || e.ctrlKey) && e.keyCode == 13) {
if ((e.metaKey || e.ctrlKey) && e.keyCode === 13) {
if (!this.sendingDissabled) {
this.submit()
}
}
if ((e.metaKey || e.ctrlKey) && e.keyCode == 75) {
else if ((e.metaKey || e.ctrlKey) && e.keyCode === 75) {
this.$refs.replyEditor.insertLink()
}
else if (e.keyCode === 27) {
this.cancelEditing()
}
},
submit() {
switch(this.editingType) {
Expand Down
10 changes: 8 additions & 2 deletions desk/src/pages/portal/Ticket.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
>
Send
</Button>
<Button @click="() => {editing = false}">Cancel</Button>
<Button @click="cancelEditing">Cancel</Button>
<div class="flex flex-row items-center space-x-2">
<CustomIcons :class="showTextFormattingMenu ? 'bg-gray-200' : ''" name="text-formatting" class="h-7 w-7 rounded p-1" role="button" @click="() => { showTextFormattingMenu = !showTextFormattingMenu}"/>
<FileUploader @success="(file) => attachments.push(file)">
Expand Down Expand Up @@ -209,15 +209,21 @@ export default {
this.submitConversation()
}
}
if ((e.metaKey || e.ctrlKey) && e.keyCode == 75) {
else if ((e.metaKey || e.ctrlKey) && e.keyCode == 75) {
this.$refs.replyEditor.insertLink()
}
else if (e.keyCode === 27) {
this.cancelEditing()
}
},
startEditing() {
this.editing = true
this.delayedConversationScroll()
this.$refs.replyEditor.focusEditor()
},
cancelEditing() {
this.editing = false
},
delayedConversationScroll() {
function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
Expand Down

0 comments on commit c7331ed

Please sign in to comment.