more bugfixes related to keybinds and nonworking stuff

This commit is contained in:
Henry Jameson 2019-06-09 21:17:24 +03:00
parent 20923d590c
commit 8a02647de4
2 changed files with 6 additions and 5 deletions

View file

@ -31,10 +31,10 @@ const EmojiInput = {
computed: { computed: {
suggestions () { suggestions () {
const firstchar = this.textAtCaret.charAt(0) const firstchar = this.textAtCaret.charAt(0)
if (this.textAtCaret === firstchar) { return } if (this.textAtCaret === firstchar) { return [] }
const matchedSuggestions = this.suggest(this.textAtCaret) const matchedSuggestions = this.suggest(this.textAtCaret)
if (matchedSuggestions.length <= 0) { if (matchedSuggestions.length <= 0) {
return false return []
} }
return take(matchedSuggestions, 5) return take(matchedSuggestions, 5)
.map(({ imageUrl, ...rest }, index) => ({ .map(({ imageUrl, ...rest }, index) => ({
@ -89,7 +89,7 @@ const EmojiInput = {
this.caret = 0 this.caret = 0
}, },
replaceText (e) { replaceText (e) {
const len = (this.suggestions && this.suggestions.length) || 0 const len = this.suggestions.length || 0
if (this.textAtCaret.length === 1) { return } if (this.textAtCaret.length === 1) { return }
if (len > 0) { if (len > 0) {
const suggestion = this.suggestions[this.highlighted] const suggestion = this.suggestions[this.highlighted]
@ -108,6 +108,7 @@ const EmojiInput = {
if (this.highlighted < 0) { if (this.highlighted < 0) {
this.highlighted = this.suggestions.length - 1 this.highlighted = this.suggestions.length - 1
} }
e.preventDefault()
} else { } else {
this.highlighted = 0 this.highlighted = 0
} }
@ -119,6 +120,7 @@ const EmojiInput = {
if (this.highlighted >= len) { if (this.highlighted >= len) {
this.highlighted = 0 this.highlighted = 0
} }
e.preventDefault()
} else { } else {
this.highlighted = 0 this.highlighted = 0
} }
@ -158,7 +160,6 @@ const EmojiInput = {
} }
if (key === 'ArrowUp') { if (key === 'ArrowUp') {
this.cycleBackward(e) this.cycleBackward(e)
e.preventDefault()
} else if (key === 'ArrowDown') { } else if (key === 'ArrowDown') {
this.cycleForward(e) this.cycleForward(e)
} }

View file

@ -92,7 +92,7 @@ const UserSettings = {
}) })
}, },
emojiSuggestor () { emojiSuggestor () {
suggestor({ emoji: [ return suggestor({ emoji: [
...this.$store.state.instance.emoji, ...this.$store.state.instance.emoji,
...this.$store.state.instance.customEmoji ...this.$store.state.instance.customEmoji
]}) ]})