From 1039c225e928feb7f8ed573443757438d13d3225 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 30 Nov 2022 10:27:50 +0000 Subject: [PATCH] fix(ui): close modals when navigating (#253) --- components/modal/ModalDialog.vue | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/modal/ModalDialog.vue b/components/modal/ModalDialog.vue index b2a355df..0c8000da 100644 --- a/components/modal/ModalDialog.vue +++ b/components/modal/ModalDialog.vue @@ -78,6 +78,8 @@ useEventListener('keydown', (e: KeyboardEvent) => { } }) +let unsubscribe: () => void + watch(modelValue, async (v) => { if (v) { isOut = true @@ -85,8 +87,14 @@ watch(modelValue, async (v) => { setTimeout(() => { isOut = false }, 10) + + unsubscribe = useRouter().beforeEach(() => { + unsubscribe() + close() + }) } else { + unsubscribe?.() isOut = true } })