Skip to content

Commit 233f11a

Browse files
committed
Clear focus on window hide
1 parent da0c02a commit 233f11a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/components/AppContent.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<script lang="ts" setup>
22
import { ref, watch } from 'vue'
3+
import { useTauriEvent } from '../composables/useTauriEvent'
34
import { useStore } from '../stores/store'
45
import type { Option } from '../types'
6+
import { batchFn } from '../utils/batch'
57
68
const store = useStore()
79
const mainEl = ref<Option<HTMLElement>>(null)
810
9-
watch(() => store.currentPage, () => {
11+
const focus = batchFn(() => {
1012
mainEl.value?.focus()
11-
}, { flush: 'post' })
13+
})
14+
15+
watch(() => store.currentPage, focus, { flush: 'post' })
16+
useTauriEvent('window:hidden', focus)
1217
</script>
1318

1419
<template>

0 commit comments

Comments
 (0)