diff --git a/src/App.vue b/src/App.vue index 309dcca..3f31706 100644 --- a/src/App.vue +++ b/src/App.vue @@ -60,18 +60,32 @@ function setupBackButton() { } const isNavVisible = ref(true) +const isInputFocused = ref(false) -// Обработчики для показа/скрытия навигации -const hideNav = () => isNavVisible.value = false -const showNav = () => isNavVisible.value = true +const handleFocusIn = () => { + isNavVisible.value = false + isInputFocused.value = true +} +const handleFocusOut = () => { + isNavVisible.value = true + isInputFocused.value = false +} + +const blurAllInputs = () => { + // Снимаем фокус со всех активных элементов + const activeElement = document.activeElement as HTMLElement + if (activeElement && (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA')) { + activeElement.blur() + } +} onMounted(() => { toolbarStore.registerHandler("openSpacePicker", () => { isSpaceSelectorVisible.value = true; }); - document.addEventListener('focusin', hideNav) - document.addEventListener('focusout', showNav) + document.addEventListener('focusin', handleFocusIn) + document.addEventListener('focusout', handleFocusOut) if (tgApp.initData) { try { @@ -99,8 +113,8 @@ watch( onBeforeUnmount(() => { toolbarStore.unregisterHandler("openSpacePicker"); - document.removeEventListener('focusin', hideNav) - document.removeEventListener('focusout', showNav) + document.removeEventListener('focusin', handleFocusIn) + document.removeEventListener('focusout', handleFocusOut) tgApp?.BackButton?.hide(); if (backHandler) tgApp?.BackButton?.offClick(backHandler); }); @@ -121,7 +135,13 @@ onBeforeUnmount(() => {