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
pull/7207/merge
cc heart 2024-01-05 09:11:25 +08:00 committed by GitHub
parent 8696e01039
commit 4ed2868137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,6 @@
import { filterEmpty } from './props-util'; import { filterEmpty } from './props-util';
import type { VNode, VNodeProps } from 'vue'; import type { VNode, VNodeProps } from 'vue';
import { cloneVNode, isVNode } from 'vue'; import { cloneVNode, isVNode, render as VueRender } from 'vue';
import warning from './warning'; import warning from './warning';
import type { RefObject } from './createRef'; import type { RefObject } from './createRef';
type NodeProps = Record<string, any> & type NodeProps = Record<string, any> &
@ -51,3 +51,7 @@ export function deepCloneElement<T, U>(
return cloned; return cloned;
} }
} }
export function triggerVNodeUpdate(vm: VNode, attrs: Record<string, any>, dom: any) {
VueRender(cloneVNode(vm, { ...attrs }), dom);
}

View File

@ -3,6 +3,7 @@ import ConfirmDialog from './ConfirmDialog';
import type { ModalFuncProps } from './Modal'; import type { ModalFuncProps } from './Modal';
import ConfigProvider, { globalConfigForApi } from '../config-provider'; import ConfigProvider, { globalConfigForApi } from '../config-provider';
import omit from '../_util/omit'; import omit from '../_util/omit';
import { triggerVNodeUpdate } from '../_util/vnode';
import { getConfirmLocale } from './locale'; import { getConfirmLocale } from './locale';
import destroyFns from './destroyFns'; import destroyFns from './destroyFns';
@ -70,8 +71,7 @@ const confirm = (config: ModalFuncProps) => {
}; };
} }
if (confirmDialogInstance) { if (confirmDialogInstance) {
Object.assign(confirmDialogInstance.component.props, currentConfig); triggerVNodeUpdate(confirmDialogInstance, currentConfig, container);
confirmDialogInstance.component.update();
} }
} }