From a98ea33ae28e5dd559eb666a96f3cdb4d98e1da8 Mon Sep 17 00:00:00 2001 From: ZhouWei <1244620067@qq.com> Date: Sat, 6 Jan 2024 21:13:40 +0800 Subject: [PATCH 1/3] fix: support vue3.4.x --- components/_util/PortalWrapper.tsx | 16 +++++------ components/_util/vnode.ts | 6 +++- components/affix/index.tsx | 6 ++-- components/modal/confirm.tsx | 5 ++-- components/upload/UploadList/index.tsx | 38 ++++++++++++++++++++++---- components/vc-select/BaseSelect.tsx | 5 ++-- 6 files changed, 52 insertions(+), 24 deletions(-) diff --git a/components/_util/PortalWrapper.tsx b/components/_util/PortalWrapper.tsx index 5c02f3ba38..e1f6e05b13 100644 --- a/components/_util/PortalWrapper.tsx +++ b/components/_util/PortalWrapper.tsx @@ -4,13 +4,12 @@ import setStyle from './setStyle'; import Portal from './Portal'; import { defineComponent, - ref, watch, onMounted, onBeforeUnmount, onUpdated, - getCurrentInstance, nextTick, + shallowRef, } from 'vue'; import canUseDom from './canUseDom'; import ScrollLocker from '../vc-util/Dom/scrollLocker'; @@ -60,9 +59,10 @@ export default defineComponent({ }, setup(props, { slots }) { - const container = ref(); - const componentRef = ref(); - const rafId = ref(); + const container = shallowRef(); + const componentRef = shallowRef(); + const rafId = shallowRef(); + const triggerUpdate = shallowRef(1); const scrollLocker = new ScrollLocker({ container: getParent(props.getContainer) as HTMLElement, }); @@ -131,7 +131,7 @@ export default defineComponent({ switchScrollingEffect(true); } }; - const instance = getCurrentInstance(); + onMounted(() => { let init = false; watch( @@ -177,7 +177,7 @@ export default defineComponent({ nextTick(() => { if (!attachToParent()) { rafId.value = raf(() => { - instance.update(); + triggerUpdate.value += 1; }); } }); @@ -203,7 +203,7 @@ export default defineComponent({ scrollLocker, }; - if (forceRender || visible || componentRef.value) { + if (triggerUpdate.value && (forceRender || visible || componentRef.value)) { portal = ( & @@ -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/affix/index.tsx b/components/affix/index.tsx index 414a2bffdd..822a3eccf6 100644 --- a/components/affix/index.tsx +++ b/components/affix/index.tsx @@ -167,7 +167,6 @@ const Affix = defineComponent({ affixStyle: undefined, placeholderStyle: undefined, }); - currentInstance.update(); // Test if `updatePosition` called if (process.env.NODE_ENV === 'test') { emit('testUpdatePosition'); @@ -247,7 +246,7 @@ const Affix = defineComponent({ const { prefixCls } = useConfigInject('affix', props); return () => { - const { affixStyle, placeholderStyle } = state; + const { affixStyle, placeholderStyle, status } = state; const className = classNames({ [prefixCls.value]: affixStyle, }); @@ -261,7 +260,8 @@ const Affix = defineComponent({ ]); return ( -
+
+ {affixStyle &&