tg app fix
This commit is contained in:
36
src/App.vue
36
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(() => {
|
||||
<div class="flex flex-col w-full h-full items-end px-4 gap-4 pb-6">
|
||||
<router-view class="w-full" />
|
||||
</div>
|
||||
|
||||
<button
|
||||
v-if="isInputFocused"
|
||||
@click="blurAllInputs"
|
||||
class="fixed bottom-4 right-4 z-50 bg-blue-500 text-white px-4 py-2 rounded-lg shadow-lg"
|
||||
>
|
||||
Готово
|
||||
</button>
|
||||
<nav v-if="isNavVisible"
|
||||
class="fixed inset-x-0 bottom-4 z-50 w-full flex justify-center items-center"
|
||||
style="padding-bottom: var(--tg-content-safe-area-inset-bottom) !important;"
|
||||
|
||||
Reference in New Issue
Block a user