Merge pull request #6977 from yanhao98/fix-DynamicDialog

fix(DynamicDialog): delay instance removal until after hide animation
master
Tuğçe Küçükoğlu 2024-12-20 10:43:54 +03:00 committed by GitHub
commit 7d5c03d904
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -1,6 +1,6 @@
<template> <template>
<template v-for="(instance, key) in instanceMap" :key="key"> <template v-for="(instance, key) in instanceMap" :key="key">
<DDialog v-model:visible="instance.visible" :_instance="instance" v-bind="instance.options.props" @hide="onDialogHide(instance)" @after-hide="onDialogAfterHide"> <DDialog v-model:visible="instance.visible" :_instance="instance" v-bind="instance.options.props" @hide="onDialogHide(instance)" @after-hide="onDialogAfterHide(instance)">
<template v-if="instance.options.templates && instance.options.templates.header" #header> <template v-if="instance.options.templates && instance.options.templates.header" #header>
<component v-for="(header, index) in getTemplateItems(instance.options.templates.header)" :is="header" :key="index + '_header'" v-bind="instance.options.emits"></component> <component v-for="(header, index) in getTemplateItems(instance.options.templates.header)" :is="header" :key="index + '_header'" v-bind="instance.options.emits"></component>
</template> </template>
@ -61,11 +61,11 @@ export default {
methods: { methods: {
onDialogHide(instance) { onDialogHide(instance) {
!this.currentInstance && instance.options.onClose && instance.options.onClose({ type: 'dialog-close' }); !this.currentInstance && instance.options.onClose && instance.options.onClose({ type: 'dialog-close' });
delete this.instanceMap[instance.key];
}, },
onDialogAfterHide() { onDialogAfterHide(instance) {
this.currentInstance && delete this.currentInstance; this.currentInstance && delete this.currentInstance;
this.currentInstance = null; this.currentInstance = null;
delete this.instanceMap[instance.key];
}, },
getTemplateItems(template) { getTemplateItems(template) {
return Array.isArray(template) ? template : [template]; return Array.isArray(template) ? template : [template];