Сделал перемещение фокуса на поле ввода после закрытия модалки
This commit is contained in:
+9
-2
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user