From 1036440c99f3af17c103235353e80730365e3816 Mon Sep 17 00:00:00 2001 From: Muyao Date: Thu, 29 Jul 2021 17:20:30 +0800 Subject: [PATCH] fix(element): fix protal destroy (#1898) --- packages/element/src/__builtins__/shared/portal.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/element/src/__builtins__/shared/portal.ts b/packages/element/src/__builtins__/shared/portal.ts index c1f99a6e977..7ec16985648 100644 --- a/packages/element/src/__builtins__/shared/portal.ts +++ b/packages/element/src/__builtins__/shared/portal.ts @@ -1,4 +1,4 @@ -import { defineComponent, getCurrentInstance } from '@vue/composition-api' +import { defineComponent, onBeforeUnmount } from '@vue/composition-api' import { h, Fragment } from '@formily/vue' export interface IPortalProps { id?: string | symbol @@ -12,10 +12,19 @@ export const createPortalProvider = (id: string | symbol) => { props: { id: { type: [String, Symbol], - default: 'form-dialog', + default: id, }, }, + setup(props) { + onBeforeUnmount(() => { + const { id } = props + if (id && PortalMap.has(id)) { + PortalMap.delete(id) + } + }) + }, + render() { const { id } = this if (id && !PortalMap.has(id)) {