diff --git a/src/components/emoji-selector/emoji-selector.js b/src/components/emoji-selector/emoji-selector.js index 6d45df1f..969b880b 100644 --- a/src/components/emoji-selector/emoji-selector.js +++ b/src/components/emoji-selector/emoji-selector.js @@ -3,6 +3,12 @@ const filterByKeyword = (list, keyword = '') => { } const EmojiSelector = { + mounted () { + document.body.addEventListener('click', this.outsideClicked) + }, + destroyed () { + document.body.removeEventListener('click', this.outsideClicked) + }, data () { return { open: false, @@ -14,6 +20,12 @@ const EmojiSelector = { togglePanel () { this.open = !this.open }, + insideClicked (e) { + e.stopPropagation() + }, + outsideClicked () { + this.open = false + }, onEmoji (emoji) { const value = emoji.image_url ? `:${emoji.shortcode}:` : emoji.utf this.$emit('emoji', ` ${value} `) diff --git a/src/components/emoji-selector/emoji-selector.vue b/src/components/emoji-selector/emoji-selector.vue index d5d63543..98d2642e 100644 --- a/src/components/emoji-selector/emoji-selector.vue +++ b/src/components/emoji-selector/emoji-selector.vue @@ -1,6 +1,6 @@