-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Auto close dialogs on route change
- Loading branch information
1 parent
da2c5d0
commit 0393bc2
Showing
7 changed files
with
35 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<template> | ||
<Dialog v-bind="attrs" ref="dialogRef" @update:modelValue="emit('update:modelValue', $event)"> | ||
<template v-for="(_, name) in $slots" :key="name" v-slot:[name]="slotData"> | ||
<slot :name="name" v-bind="slotData"></slot> | ||
</template> | ||
</Dialog> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Dialog } from "frappe-ui"; | ||
import { ref, useAttrs, watch } from "vue"; | ||
import { useRoute } from "vue-router"; | ||
const attrs = useAttrs(); | ||
const emit = defineEmits(["update:modelValue", "close"]); | ||
const route = useRoute(); | ||
const dialogRef = ref(); | ||
// close dialog on route change | ||
watch( | ||
() => route.fullPath, | ||
() => { | ||
if (attrs.modelValue) { | ||
emit("update:modelValue", false); | ||
} | ||
}, | ||
); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters