fix: opt group label (#3868)

pull/3884/head
zkwolf 2021-03-28 20:28:08 +08:00 committed by GitHub
parent ad3aaec3ca
commit db2e3599ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -37,17 +37,18 @@ export function convertChildrenToData(
props, props,
} = node as VNode & { } = node as VNode & {
type: { isSelectOptGroup?: boolean }; type: { isSelectOptGroup?: boolean };
children: { default?: () => any }; children: { default?: () => any; label?: () => any };
}; };
if (optionOnly || !isSelectOptGroup) { if (optionOnly || !isSelectOptGroup) {
return convertNodeToOption(node); return convertNodeToOption(node);
} }
const child = children && children.default ? children.default() : undefined; const child = children && children.default ? children.default() : undefined;
const label = props?.label || children.label?.() || key;
return { return {
key: `__RC_SELECT_GRP__${key === null ? index : key}__`, key: `__RC_SELECT_GRP__${key === null ? index : key}__`,
label: key,
...props, ...props,
label,
options: convertChildrenToData(child || []), options: convertChildrenToData(child || []),
} as any; } as any;
}) })