#101 - click outside of emoji implementation
This commit is contained in:
parent
820a6543c7
commit
2ab915b486
2 changed files with 15 additions and 3 deletions
|
@ -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} `)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue