Skip to content

Commit 3e3820a

Browse files
committed
feat: overwrite displayDirective to show if keepAlive is true
1 parent 8b0b6f7 commit 3e3820a

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

packages/vue-final-modal/src/components/ModalsContainer.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ onBeforeUnmount(() => {
2121
:is="modal.component"
2222
v-for="(modal, index) in vfm.dynamicModals"
2323
:key="modal.id"
24-
v-bind="modal.attrs"
24+
v-bind="{
25+
displayDirective: modal.keepAlive ? 'show' : undefined,
26+
...modal.attrs,
27+
}"
2528
v-model="modal.modelValue"
2629
@closed="() => _vfm.resolvedClosed?.(index)"
2730
@opened="() => _vfm.resolvedOpened?.(index)"

viteplay/src/components/DefaultSlot.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts" setup>
2+
import { ref } from 'vue'
3+
24
defineProps<{
35
text: string
46
}>()
@@ -8,11 +10,14 @@ const emit = defineEmits<{
810
}>()
911
1012
emit('create')
13+
14+
const count = ref(0)
1115
</script>
1216

1317
<template>
1418
<div style="height: 500px;">
1519
<div>default slot component {{ text }}</div>
1620
<button>Click Button!</button>
21+
<input v-model="count" type="number">
1722
</div>
1823
</template>

viteplay/src/components/VueFinalModal/Basic.example.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import TestModal from './TestModal.vue'
77
const { toggle, closeAll } = useVfm()
88
99
const modal1 = useModal({
10+
keepAlive: true,
1011
component: VueFinalModal,
1112
attrs: {
12-
'displayDirective': 'if',
13+
// 'displayDirective': 'if',
1314
'background': 'interactive',
1415
'lockScroll': false,
1516
'contentStyle': { backgroundColor: '#fff' },

0 commit comments

Comments
 (0)