Сделал перемещение фокуса на поле ввода после закрытия модалки

This commit is contained in:
Ilia Miheev
2026-06-24 20:13:51 +03:00
parent 5b3c9f5fcf
commit d7846ea923
+9 -2
View File
@@ -1,11 +1,12 @@
<script setup>
import { computed, onMounted, onUnmounted, watch } from 'vue'
import { computed, onMounted, onUnmounted, watch, nextTick, ref } from 'vue'
import { useTheme } from './composables/useTheme'
import { useQrCode } from './composables/useQrCode'
import { useAppConfig } from './composables/useAppConfig'
const config = useAppConfig()
const { isLightTheme, toggleTheme } = useTheme()
const textInputRef = ref(null)
const {
textInput,
@@ -34,8 +35,13 @@ function onKeydown(event) {
}
}
watch(showModal, (open) => {
watch(showModal, async (open) => {
document.body.style.overflow = open ? 'hidden' : ''
if (!open) {
await nextTick()
textInputRef.value?.focus()
}
})
onMounted(() => {
@@ -67,6 +73,7 @@ onUnmounted(() => {
<div class="inputs">
<textarea
ref="textInputRef"
v-model="textInput"
cols="30"
rows="3"