feat: add skipFlatten

pull/5820/head
tangjinzhou 2022-05-16 14:31:46 +08:00
parent f00b9535d2
commit e4f678f665
2 changed files with 8 additions and 4 deletions

View File

@ -78,7 +78,11 @@ const flattenChildren = (children = [], filterEmpty = true) => {
if (Array.isArray(child)) { if (Array.isArray(child)) {
res.push(...flattenChildren(child, filterEmpty)); res.push(...flattenChildren(child, filterEmpty));
} else if (child && child.type === Fragment) { } else if (child && child.type === Fragment) {
if (child.props && child.props.skipFlatten) {
res.push(child);
} else {
res.push(...flattenChildren(child.children, filterEmpty)); res.push(...flattenChildren(child.children, filterEmpty));
}
} else if (child && isVNode(child)) { } else if (child && isVNode(child)) {
if (filterEmpty && !isEmptyElement(child)) { if (filterEmpty && !isEmptyElement(child)) {
res.push(child); res.push(child);

View File

@ -1,5 +1,5 @@
import type { CSSProperties, PropType } from 'vue'; 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 PropTypes from '../_util/vue-types';
import Trigger from '../vc-trigger'; import Trigger from '../vc-trigger';
import placements from './placements'; import placements from './placements';
@ -72,10 +72,10 @@ export default defineComponent({
getPopupContainer: () => triggerRef.value.getPopupDomNode(), getPopupContainer: () => triggerRef.value.getPopupDomNode(),
}; };
return ( return (
<> <Fragment skipFlatten>
{props.arrow && <div class={`${props.prefixCls}-arrow`} />} {props.arrow && <div class={`${props.prefixCls}-arrow`} />}
{cloneElement(overlayElement, extraOverlayProps, false)} {cloneElement(overlayElement, extraOverlayProps, false)}
</> </Fragment>
); );
}; };