Merge branch 'emoji-popovers' into shigusegubu-vue3
* emoji-popovers: better autocomplete handling, fix leak focus search input when opening emoji picker
This commit is contained in:
commit
9de6ac5abb
3 changed files with 13 additions and 21 deletions
|
|
@ -145,7 +145,7 @@ const EmojiInput = {
|
||||||
!this.temporarilyHideSuggestions
|
!this.temporarilyHideSuggestions
|
||||||
},
|
},
|
||||||
textAtCaret () {
|
textAtCaret () {
|
||||||
return (this.wordAtCaret || {}).word || ''
|
return this.wordAtCaret?.word
|
||||||
},
|
},
|
||||||
wordAtCaret () {
|
wordAtCaret () {
|
||||||
if (this.modelValue && this.caret) {
|
if (this.modelValue && this.caret) {
|
||||||
|
|
@ -197,6 +197,12 @@ const EmojiInput = {
|
||||||
|
|
||||||
return emoji.displayText
|
return emoji.displayText
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
onInputScroll () {
|
||||||
|
this.$refs.hiddenOverlay.scrollTo({
|
||||||
|
top: this.input.scrollTop,
|
||||||
|
left: this.input.scrollLeft
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
|
|
@ -225,13 +231,7 @@ const EmojiInput = {
|
||||||
input.addEventListener('click', this.onClickInput)
|
input.addEventListener('click', this.onClickInput)
|
||||||
input.addEventListener('transitionend', this.onTransition)
|
input.addEventListener('transitionend', this.onTransition)
|
||||||
input.addEventListener('input', this.onInput)
|
input.addEventListener('input', this.onInput)
|
||||||
// FIXME LEAK
|
input.addEventListener('scroll', this.onInputScroll)
|
||||||
input.addEventListener('scroll', (e) => {
|
|
||||||
this.$refs.hiddenOverlay.scrollTo({
|
|
||||||
top: this.input.scrollTop,
|
|
||||||
left: this.input.scrollLeft
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
unmounted () {
|
unmounted () {
|
||||||
const { input } = this
|
const { input } = this
|
||||||
|
|
@ -244,6 +244,7 @@ const EmojiInput = {
|
||||||
input.removeEventListener('click', this.onClickInput)
|
input.removeEventListener('click', this.onClickInput)
|
||||||
input.removeEventListener('transitionend', this.onTransition)
|
input.removeEventListener('transitionend', this.onTransition)
|
||||||
input.removeEventListener('input', this.onInput)
|
input.removeEventListener('input', this.onInput)
|
||||||
|
input.removeEventListener('scroll', this.onInputScroll)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
@ -256,11 +257,10 @@ const EmojiInput = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
textAtCaret: async function (newWord) {
|
textAtCaret: async function (newWord) {
|
||||||
|
if (newWord === undefined) return
|
||||||
const firstchar = newWord.charAt(0)
|
const firstchar = newWord.charAt(0)
|
||||||
if (newWord === firstchar) {
|
if (newWord === firstchar) {
|
||||||
if (firstchar === ' ') {
|
this.suggestions = []
|
||||||
this.suggestions = []
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const matchedSuggestions = await this.suggest(newWord, this.maybeLocalizedEmojiNamesAndKeywords)
|
const matchedSuggestions = await this.suggest(newWord, this.maybeLocalizedEmojiNamesAndKeywords)
|
||||||
|
|
@ -278,17 +278,10 @@ const EmojiInput = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
focusPickerInput () {
|
|
||||||
const pickerEl = this.$refs.picker.$el
|
|
||||||
if (!pickerEl) return
|
|
||||||
const pickerInput = pickerEl.querySelector('input')
|
|
||||||
if (pickerInput) pickerInput.focus()
|
|
||||||
},
|
|
||||||
triggerShowPicker () {
|
triggerShowPicker () {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.picker.showPicker()
|
this.$refs.picker.showPicker()
|
||||||
this.scrollIntoView()
|
this.scrollIntoView()
|
||||||
this.focusPickerInput()
|
|
||||||
})
|
})
|
||||||
// This temporarily disables "click outside" handler
|
// This temporarily disables "click outside" handler
|
||||||
// since external trigger also means click originates
|
// since external trigger also means click originates
|
||||||
|
|
@ -299,14 +292,11 @@ const EmojiInput = {
|
||||||
}, 0)
|
}, 0)
|
||||||
},
|
},
|
||||||
togglePicker () {
|
togglePicker () {
|
||||||
console.log('piick')
|
|
||||||
this.input.focus()
|
this.input.focus()
|
||||||
if (!this.pickerShown) {
|
if (!this.pickerShown) {
|
||||||
console.log('pick')
|
|
||||||
this.scrollIntoView()
|
this.scrollIntoView()
|
||||||
this.$refs.picker.showPicker()
|
this.$refs.picker.showPicker()
|
||||||
this.$refs.picker.startEmojiLoad()
|
this.$refs.picker.startEmojiLoad()
|
||||||
this.$nextTick(this.focusPickerInput)
|
|
||||||
} else {
|
} else {
|
||||||
this.$refs.picker.hidePicker()
|
this.$refs.picker.hidePicker()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,7 @@ const EmojiPicker = {
|
||||||
this.filteredEmojiGroups = this.getFilteredEmojiGroups()
|
this.filteredEmojiGroups = this.getFilteredEmojiGroups()
|
||||||
if (!oldContentLoaded) {
|
if (!oldContentLoaded) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
|
this.$refs.search.focus()
|
||||||
if (this.defaultGroup) {
|
if (this.defaultGroup) {
|
||||||
this.highlight(this.defaultGroup)
|
this.highlight(this.defaultGroup)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@
|
||||||
class="form-control"
|
class="form-control"
|
||||||
:placeholder="$t('emoji.search_emoji')"
|
:placeholder="$t('emoji.search_emoji')"
|
||||||
@input="$event.target.composing = false"
|
@input="$event.target.composing = false"
|
||||||
|
ref="search"
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue