補完でタブが効かなくなるケースを修正 (#6779)

This commit is contained in:
takonomura 2020-10-31 09:43:28 +09:00 committed by GitHub
parent cb16cb0610
commit 3bfae80fa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -122,6 +122,7 @@ export default defineComponent({
users: [], users: [],
hashtags: [], hashtags: [],
emojis: [], emojis: [],
items: [],
select: -1, select: -1,
emojilist, emojilist,
emojiDb: [] as EmojiDef[] emojiDb: [] as EmojiDef[]
@ -129,10 +130,6 @@ export default defineComponent({
}, },
computed: { computed: {
items(): HTMLCollection {
return (this.$refs.suggests as Element).children;
},
useOsNativeEmojis(): boolean { useOsNativeEmojis(): boolean {
return this.$store.state.device.useOsNativeEmojis; return this.$store.state.device.useOsNativeEmojis;
} }
@ -148,6 +145,7 @@ export default defineComponent({
updated() { updated() {
this.setPosition(); this.setPosition();
this.items = (this.$refs.suggests as Element | undefined)?.children || [];
}, },
mounted() { mounted() {
@ -371,6 +369,7 @@ export default defineComponent({
selectNext() { selectNext() {
if (++this.select >= this.items.length) this.select = 0; if (++this.select >= this.items.length) this.select = 0;
if (this.items.length === 0) this.select = -1;
this.applySelect(); this.applySelect();
}, },
@ -384,8 +383,10 @@ export default defineComponent({
el.removeAttribute('data-selected'); el.removeAttribute('data-selected');
} }
this.items[this.select].setAttribute('data-selected', 'true'); if (this.select !== -1) {
(this.items[this.select] as any).focus(); this.items[this.select].setAttribute('data-selected', 'true');
(this.items[this.select] as any).focus();
}
}, },
chooseUser() { chooseUser() {