Skip to content

Commit 14137d6

Browse files
committed
fix: use watcher for focus trap activation to avoid UI blocking
- Watch isAuthPanelOpen instead of manual activation - Simplify openAuthPanel function - Fix causes blocking after login/logout
1 parent 7fdaeaf commit 14137d6

1 file changed

Lines changed: 14 additions & 9 deletions

File tree

src/App.vue

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { computed, onMounted, ref, nextTick } from 'vue'
2+
import { computed, onMounted, ref, nextTick, watch } from 'vue'
33
import { useFocusTrap } from '@vueuse/integrations/useFocusTrap'
44
55
import ApplicationForm from './components/ApplicationForm.vue'
@@ -40,6 +40,19 @@ const { activate: activateAuthTrap, deactivate: deactivateAuthTrap } = useFocusT
4040
allowOutsideClick: false,
4141
})
4242
43+
watch(isAuthPanelOpen, async (isOpen) => {
44+
if (isOpen) {
45+
await nextTick()
46+
try {
47+
activateAuthTrap()
48+
} catch (e) {
49+
console.warn('Auth focus trap skipped:', e)
50+
}
51+
} else {
52+
deactivateAuthTrap()
53+
}
54+
})
55+
4356
const statusRank = new Map(APPLICATION_STATUSES.map((status, index) => [status, index]))
4457
4558
const editingApplication = computed(() => {
@@ -129,18 +142,10 @@ function clearAlerts(): void {
129142
130143
function openAuthPanel(): void {
131144
isAuthPanelOpen.value = true
132-
nextTick(() => {
133-
try {
134-
activateAuthTrap()
135-
} catch (e) {
136-
console.warn('Auth focus trap skipped:', e)
137-
}
138-
})
139145
}
140146
141147
function closeAuthPanel(): void {
142148
isAuthPanelOpen.value = false
143-
deactivateAuthTrap()
144149
}
145150
146151
function openCreateForm(): void {

0 commit comments

Comments
 (0)