Skip to content

Commit 8d75d85

Browse files
IcetCodejd-solanki
andauthored
fix(drawer,dialog): handle persistent prop reactivity (#153)
Co-authored-by: JD Solanki <jdsolanki0001@gmail.com>
1 parent 54b6c06 commit 8d75d85

File tree

2 files changed

+11
-19
lines changed

2 files changed

+11
-19
lines changed

packages/anu-vue/src/components/dialog/ADialog.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script lang="ts" setup>
2-
import type { Ref } from 'vue'
32
import { ACard, cardProps } from '@/components/card'
43
import { useDOMScrollLock } from '@/composables/useDOMScrollLock'
54
import { defuProps } from '@/composables/useProps'
65
import { useTeleport } from '@/composables/useTeleport'
6+
import type { Ref } from 'vue'
77
88
const props = defineProps(defuProps({
99
/**
@@ -30,15 +30,11 @@ const { teleportTarget } = useTeleport()
3030
const isMounted = useMounted()
3131
3232
const refCard = ref()
33-
if (!props.persistent) {
34-
onClickOutside(refCard, () => {
35-
// If dialog is not open => Don't execute
36-
if (!props.modelValue)
37-
return
38-
33+
onClickOutside(refCard, () => {
34+
// If dialog is open & persistent prop is false => Close dialog
35+
if (props.modelValue && !props.persistent)
3936
emit('update:modelValue', false)
40-
})
41-
}
37+
})
4238
4339
// Lock DOM scroll when modelValue is `true`
4440
// ℹ️ We need to use type assertion here because of this issue: https://github.com/johnsoncodehk/volar/issues/2219

packages/anu-vue/src/components/drawer/ADrawer.vue

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<script lang="ts" setup>
2-
import { defu } from 'defu'
3-
import type { PropType, Ref } from 'vue'
42
import { ACard, cardProps } from '@/components/card'
53
import { useDOMScrollLock } from '@/composables/useDOMScrollLock'
64
import { useTeleport } from '@/composables/useTeleport'
5+
import { defu } from 'defu'
6+
import type { PropType, Ref } from 'vue'
77
88
const props = defineProps(defu({
99
/**
@@ -38,15 +38,11 @@ const { teleportTarget } = useTeleport()
3838
const isMounted = useMounted()
3939
4040
const refCard = ref()
41-
if (!props.persistent) {
42-
onClickOutside(refCard, () => {
43-
// If dialog is not open => Don't execute
44-
if (!props.modelValue)
45-
return
46-
41+
onClickOutside(refCard, () => {
42+
// If dialog is open & persistent prop is false => Close drawer
43+
if (props.modelValue && !props.persistent)
4744
emit('update:modelValue', false)
48-
})
49-
}
45+
})
5046
5147
const transitionName = computed(() => {
5248
if (props.anchor === 'bottom')

0 commit comments

Comments
 (0)