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 001/117] 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 1f8265c2d9..e5ab010a42 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 88959f73f7..80bd620823 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); } } From d7f9bd27dc748f3c525cee5ab53377a9b6e5f083 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Fri, 5 Jan 2024 16:20:05 +0800 Subject: [PATCH 002/117] fix: support vue 3.4 --- components/_util/PortalWrapper.tsx | 8 +++---- components/affix/index.tsx | 5 ++--- components/modal/confirm.tsx | 1 - components/upload/UploadList/index.tsx | 30 ++++++++++++++++++++------ components/vc-input/Input.tsx | 17 +++++---------- components/vc-select/BaseSelect.tsx | 5 ++--- 6 files changed, 36 insertions(+), 30 deletions(-) diff --git a/components/_util/PortalWrapper.tsx b/components/_util/PortalWrapper.tsx index 1ef3d6e7ce..91561990bf 100644 --- a/components/_util/PortalWrapper.tsx +++ b/components/_util/PortalWrapper.tsx @@ -7,7 +7,6 @@ import { onMounted, onBeforeUnmount, onUpdated, - getCurrentInstance, nextTick, computed, } from 'vue'; @@ -61,6 +60,7 @@ export default defineComponent({ const container = shallowRef(); const componentRef = shallowRef(); const rafId = shallowRef(); + const triggerUpdate = shallowRef(1); const defaultContainer = canUseDom() && document.createElement('div'); const removeCurrentContainer = () => { // Portal will remove from `parentNode`. @@ -106,8 +106,6 @@ export default defineComponent({ attachToParent(); }); - const instance = getCurrentInstance(); - useScrollLocker( computed(() => { return ( @@ -155,7 +153,7 @@ export default defineComponent({ nextTick(() => { if (!attachToParent()) { rafId.value = raf(() => { - instance.update(); + triggerUpdate.value += 1; }); } }); @@ -177,7 +175,7 @@ export default defineComponent({ getOpenCount: () => openCount, getContainer, }; - if (forceRender || visible || componentRef.value) { + if (triggerUpdate.value && (forceRender || visible || componentRef.value)) { portal = ( { - const { affixStyle, placeholderStyle } = state; + const { affixStyle, placeholderStyle, status } = state; const className = classNames({ [prefixCls.value]: affixStyle, [hashId.value]: true, @@ -271,7 +270,7 @@ const Affix = defineComponent({ ]); return wrapSSR( -
+
{affixStyle &&