From 4ed286813758fb0021b80f8b03e140253e932e5f Mon Sep 17 00:00:00 2001 From: cc heart <71313168+cc-hearts@users.noreply.github.com> Date: Fri, 5 Jan 2024 09:11:25 +0800 Subject: [PATCH] fix(vue): fixed modal component failed to trigger update in vue@3.4.x (#7244) * fix(vue): fixed modal component failed to trigger update in vue@3.4.x version * refactor: use cloneVNode trigger vNode update --- components/_util/vnode.ts | 6 +++++- components/modal/confirm.tsx | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/_util/vnode.ts b/components/_util/vnode.ts index 1f8265c2d..e5ab010a4 100644 --- a/components/_util/vnode.ts +++ b/components/_util/vnode.ts @@ -1,6 +1,6 @@ import { filterEmpty } from './props-util'; import type { VNode, VNodeProps } from 'vue'; -import { cloneVNode, isVNode } from 'vue'; +import { cloneVNode, isVNode, render as VueRender } from 'vue'; import warning from './warning'; import type { RefObject } from './createRef'; type NodeProps = Record & @@ -51,3 +51,7 @@ export function deepCloneElement( return cloned; } } + +export function triggerVNodeUpdate(vm: VNode, attrs: Record, dom: any) { + VueRender(cloneVNode(vm, { ...attrs }), dom); +} diff --git a/components/modal/confirm.tsx b/components/modal/confirm.tsx index 88959f73f..80bd62082 100644 --- a/components/modal/confirm.tsx +++ b/components/modal/confirm.tsx @@ -3,6 +3,7 @@ import ConfirmDialog from './ConfirmDialog'; import type { ModalFuncProps } from './Modal'; import ConfigProvider, { globalConfigForApi } from '../config-provider'; import omit from '../_util/omit'; +import { triggerVNodeUpdate } from '../_util/vnode'; import { getConfirmLocale } from './locale'; import destroyFns from './destroyFns'; @@ -70,8 +71,7 @@ const confirm = (config: ModalFuncProps) => { }; } if (confirmDialogInstance) { - Object.assign(confirmDialogInstance.component.props, currentConfig); - confirmDialogInstance.component.update(); + triggerVNodeUpdate(confirmDialogInstance, currentConfig, container); } }