From 80fbabc66fce502738bce93431c38aa1e0108df3 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Thu, 27 Apr 2023 22:18:35 +0800 Subject: [PATCH] fix: space remounted slot, close #6500 --- components/space/index.tsx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/components/space/index.tsx b/components/space/index.tsx index b53128895..055f6469f 100644 --- a/components/space/index.tsx +++ b/components/space/index.tsx @@ -1,5 +1,5 @@ import type { PropType, ExtractPropTypes, CSSProperties } from 'vue'; -import { defineComponent, computed, ref, watch } from 'vue'; +import { defineComponent, computed, ref, watch, Fragment } from 'vue'; import PropTypes from '../_util/vue-types'; import { filterEmpty } from '../_util/props-util'; import type { SizeType } from '../config-provider'; @@ -80,8 +80,8 @@ const Space = defineComponent({ }); return () => { const { wrap, direction = 'horizontal' } = props; - - const items = filterEmpty(slots.default?.()); + const children = slots.default?.(); + const items = filterEmpty(children); const len = items.length; if (len === 0) { @@ -94,6 +94,7 @@ const Space = defineComponent({ return (
{items.map((child, index) => { + const originIndex = children.indexOf(child); let itemStyle: CSSProperties = {}; if (!supportFlexGap.value) { if (direction === 'vertical') { @@ -111,7 +112,7 @@ const Space = defineComponent({ } return ( - <> +
{child}
@@ -120,7 +121,7 @@ const Space = defineComponent({ {split} )} - +
); })}