Skip to content

Commit

Permalink
Close at-mention dropdown on blur
Browse files Browse the repository at this point in the history
When clicking outside the at-mention dropdown or exiting the input
field, the at-mention dropdown is now closed automatically.

Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Jan 20, 2021
1 parent 1c865f3 commit 488dc68
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/components/NewMessageForm/AdvancedInput/AdvancedInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
@shortkey="focusInput"
@keydown.enter="handleKeydownEnter"
@keydown.esc.prevent="handleKeydownEsc"
@blur="onBlur"
@paste="onPaste" />
</At>
</template>
Expand Down Expand Up @@ -249,6 +250,15 @@ export default {
EventBus.$off('focusChatInput', this.focusInput)
},
methods: {
onBlur() {
// requires a short delay to avoid blocking click event handlers
// from vue-at which also have some delay in place...
// a setTimeout was recommended by the library author here:
// https://github.com/fritx/vue-at/issues/114#issuecomment-565777450
setTimeout(() => {
this.$refs.at.closePanel()
}, 100)
},
onPaste(e) {
e.preventDefault()

Expand Down

0 comments on commit 488dc68

Please sign in to comment.