diff --git a/components/_util/Portal.js b/components/_util/Portal.js
index e0ca32114..3d1d898fa 100644
--- a/components/_util/Portal.js
+++ b/components/_util/Portal.js
@@ -1,48 +1,38 @@
import PropTypes from './vue-types';
-import { defineComponent, nextTick, Teleport } from 'vue';
+import {
+ defineComponent,
+ nextTick,
+ onBeforeUnmount,
+ onMounted,
+ onUpdated,
+ ref,
+ Teleport,
+} from 'vue';
export default defineComponent({
name: 'Portal',
props: {
getContainer: PropTypes.func.isRequired,
- children: PropTypes.any.isRequired,
didUpdate: PropTypes.func,
},
- data() {
- this._container = null;
- return {};
- },
- mounted() {
- this.createContainer();
- },
- updated() {
- const { didUpdate } = this.$props;
- if (didUpdate) {
+ setup(props, { slots }) {
+ const container = ref();
+
+ onMounted(() => {
+ container.value = props.getContainer();
+ });
+ onUpdated(() => {
nextTick(() => {
- didUpdate(this.$props);
+ props.didUpdate?.(props);
});
- }
- },
-
- beforeUnmount() {
- this.removeContainer();
- },
- methods: {
- createContainer() {
- this._container = this.$props.getContainer();
- this.$forceUpdate();
- },
- removeContainer() {
- if (this._container && this._container.parentNode) {
- this._container.parentNode.removeChild(this._container);
- }
- },
- },
-
- render() {
- if (this._container) {
- return {this.$props.children};
- }
- return null;
+ });
+ onBeforeUnmount(() => {
+ container.value &&
+ container.value.parentNode &&
+ container.value.parentNode.removeChild(container.value);
+ });
+ return () => {
+ return container.value ? {slots.default?.()} : null;
+ };
},
});
diff --git a/components/_util/PortalWrapper.js b/components/_util/PortalWrapper.js
index 38113023f..7c6626887 100644
--- a/components/_util/PortalWrapper.js
+++ b/components/_util/PortalWrapper.js
@@ -141,8 +141,8 @@ export default defineComponent({
portal = (
children(childProps) }}
>
);
}
diff --git a/components/vc-dialog/DialogWrap.jsx b/components/vc-dialog/DialogWrap.jsx
index ef9a2b313..6dfe9d2fc 100644
--- a/components/vc-dialog/DialogWrap.jsx
+++ b/components/vc-dialog/DialogWrap.jsx
@@ -35,9 +35,11 @@ const DialogWrap = defineComponent({
visible={visible}
forceRender={forceRender}
getContainer={getContainer}
- children={childProps => {
- dialogProps = { ...dialogProps, ...childProps };
- return ;
+ v-slots={{
+ default: childProps => {
+ dialogProps = { ...dialogProps, ...childProps };
+ return ;
+ },
}}
/>
);
diff --git a/components/vc-select/OptionList.tsx b/components/vc-select/OptionList.tsx
index a61876512..be343cc2b 100644
--- a/components/vc-select/OptionList.tsx
+++ b/components/vc-select/OptionList.tsx
@@ -147,22 +147,20 @@ const OptionList = defineComponent({
watch(
() => props.open,
() => {
- if (!props.multiple && props.open && props.values.size === 1) {
- const value = Array.from(props.values)[0];
- const index = memoFlattenOptions.value.findIndex(({ data }) => data.value === value);
- setActive(index);
- nextTick(() => {
+ nextTick(() => {
+ if (!props.multiple && props.open && props.values.size === 1) {
+ const value = Array.from(props.values)[0];
+ const index = memoFlattenOptions.value.findIndex(({ data }) => data.value === value);
+ setActive(index);
scrollIntoView(index);
- });
- }
- // Force trigger scrollbar visible when open
- if (props.open) {
- nextTick(() => {
+ }
+ // Force trigger scrollbar visible when open
+ if (props.open) {
listRef.current?.scrollTo(undefined);
- });
- }
+ }
+ });
},
- { immediate: true, flush: 'post' },
+ { immediate: true },
);
// ========================== Values ==========================
diff --git a/components/vc-select/SelectTrigger.tsx b/components/vc-select/SelectTrigger.tsx
index e9f4e9cca..39c4cf242 100644
--- a/components/vc-select/SelectTrigger.tsx
+++ b/components/vc-select/SelectTrigger.tsx
@@ -131,6 +131,7 @@ const SelectTrigger = defineComponent({
[`${dropdownPrefixCls}-empty`]: empty,
})}
popupStyle={popupStyle}
+ // destroyPopupOnHide
// getTriggerDOMNode={getTriggerDOMNode}
>
{getSlot(this)[0]}
diff --git a/components/vc-trigger/Trigger.jsx b/components/vc-trigger/Trigger.jsx
index cbc2f14e4..9e8fec0f3 100644
--- a/components/vc-trigger/Trigger.jsx
+++ b/components/vc-trigger/Trigger.jsx
@@ -648,7 +648,7 @@ export default defineComponent({
portal = (
diff --git a/v2-doc b/v2-doc
index 2924233b6..6b53258cc 160000
--- a/v2-doc
+++ b/v2-doc
@@ -1 +1 @@
-Subproject commit 2924233b60d3645d3df5e86e8bec912d3a13496d
+Subproject commit 6b53258cc2b3709e070d340714e992760e660e67