Fix focus on NewToot/Status

This commit is contained in:
AkiraFukushima 2022-05-02 21:37:27 +09:00
parent f636fd6c92
commit 88422646e7
No known key found for this signature in database
GPG Key ID: B6E51BAC4DE1A957
1 changed files with 7 additions and 5 deletions

View File

@ -71,7 +71,7 @@
<script lang="ts"> <script lang="ts">
import 'emoji-mart-vue-fast/css/emoji-mart.css' import 'emoji-mart-vue-fast/css/emoji-mart.css'
import data from 'emoji-mart-vue-fast/data/all.json' import data from 'emoji-mart-vue-fast/data/all.json'
import { defineComponent, computed, toRefs, ref, onBeforeUnmount, onMounted } from 'vue' import { defineComponent, computed, toRefs, ref, onBeforeUnmount, onMounted, nextTick } from 'vue'
import { Picker, EmojiIndex } from 'emoji-mart-vue-fast/src' import { Picker, EmojiIndex } from 'emoji-mart-vue-fast/src'
import { useMagicKeys, whenever } from '@vueuse/core' import { useMagicKeys, whenever } from '@vueuse/core'
@ -129,13 +129,13 @@ export default defineComponent({
}) })
whenever(up, () => { whenever(up, () => {
suggestHighlight(highlightedIndex.value - 1) if (suggestOpened.value) suggestHighlight(highlightedIndex.value - 1)
}) })
whenever(down, () => { whenever(down, () => {
suggestHighlight(highlightedIndex.value + 1) if (suggestOpened.value) suggestHighlight(highlightedIndex.value + 1)
}) })
whenever(enter, () => { whenever(enter, () => {
selectCurrentItem() if (suggestOpened.value) selectCurrentItem()
}) })
whenever(escape, () => { whenever(escape, () => {
closeSuggest() closeSuggest()
@ -148,8 +148,10 @@ export default defineComponent({
closeSuggest() closeSuggest()
}) })
onMounted(() => { onMounted(() => {
nextTick(() => {
statusRef.value?.focus() statusRef.value?.focus()
}) })
})
const openSuggest = () => { const openSuggest = () => {
suggestOpened.value = true suggestOpened.value = true