From db2e3599ff70a9d0a497132786374d34d5bc7dcf Mon Sep 17 00:00:00 2001 From: zkwolf Date: Sun, 28 Mar 2021 20:28:08 +0800 Subject: [PATCH] fix: opt group label (#3868) --- components/vc-select/utils/legacyUtil.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/vc-select/utils/legacyUtil.ts b/components/vc-select/utils/legacyUtil.ts index 8e1505ef93..8154e7f6e1 100644 --- a/components/vc-select/utils/legacyUtil.ts +++ b/components/vc-select/utils/legacyUtil.ts @@ -37,17 +37,18 @@ export function convertChildrenToData( props, } = node as VNode & { type: { isSelectOptGroup?: boolean }; - children: { default?: () => any }; + children: { default?: () => any; label?: () => any }; }; if (optionOnly || !isSelectOptGroup) { return convertNodeToOption(node); } const child = children && children.default ? children.default() : undefined; + const label = props?.label || children.label?.() || key; return { key: `__RC_SELECT_GRP__${key === null ? index : key}__`, - label: key, ...props, + label, options: convertChildrenToData(child || []), } as any; })