From e4f678f665f6f0577ca7956b46d53d310e181dd6 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Mon, 16 May 2022 14:31:46 +0800 Subject: [PATCH] feat: add skipFlatten --- components/_util/props-util/index.js | 6 +++++- components/vc-dropdown/Dropdown.tsx | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/components/_util/props-util/index.js b/components/_util/props-util/index.js index 49d54cd24..03215f80a 100644 --- a/components/_util/props-util/index.js +++ b/components/_util/props-util/index.js @@ -78,7 +78,11 @@ const flattenChildren = (children = [], filterEmpty = true) => { if (Array.isArray(child)) { res.push(...flattenChildren(child, filterEmpty)); } else if (child && child.type === Fragment) { - res.push(...flattenChildren(child.children, filterEmpty)); + if (child.props && child.props.skipFlatten) { + res.push(child); + } else { + res.push(...flattenChildren(child.children, filterEmpty)); + } } else if (child && isVNode(child)) { if (filterEmpty && !isEmptyElement(child)) { res.push(child); diff --git a/components/vc-dropdown/Dropdown.tsx b/components/vc-dropdown/Dropdown.tsx index 43082ae59..69c85789e 100644 --- a/components/vc-dropdown/Dropdown.tsx +++ b/components/vc-dropdown/Dropdown.tsx @@ -1,5 +1,5 @@ import type { CSSProperties, PropType } from 'vue'; -import { computed, defineComponent, ref, watch } from 'vue'; +import { Fragment, computed, defineComponent, ref, watch } from 'vue'; import PropTypes from '../_util/vue-types'; import Trigger from '../vc-trigger'; import placements from './placements'; @@ -72,10 +72,10 @@ export default defineComponent({ getPopupContainer: () => triggerRef.value.getPopupDomNode(), }; return ( - <> + {props.arrow &&
} {cloneElement(overlayElement, extraOverlayProps, false)} - + ); };