Skip to content

Commit da09588

Browse files
RSS1102uyarn
authored andcommitted
perf(select): support rendering children when group title is not exist (#3445)
1 parent 95b5855 commit da09588

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

src/select/hooks/useSelectOptions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function useSelectOptions(
4949
dynamicIndex += 1;
5050
return res;
5151
};
52-
if ((option as SelectOptionGroup).group && (option as SelectOptionGroup).children) {
52+
if ((option as SelectOptionGroup).children) {
5353
return {
5454
...option,
5555
children: (option as SelectOptionGroup).children.map((child) => getFormatOption(child)),
@@ -122,7 +122,7 @@ export default function useSelectOptions(
122122
const res: TdOptionProps[] = [];
123123
const getOptionsList = (options: TdOptionProps[]) => {
124124
options.forEach((option) => {
125-
if ((option as SelectOptionGroup).group) {
125+
if ((option as SelectOptionGroup).children) {
126126
getOptionsList((option as SelectOptionGroup).children);
127127
} else {
128128
res.push(option);

src/select/option-group-props.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,5 @@ export default {
1313
/** 分组别名 */
1414
label: {
1515
type: String,
16-
default: '',
1716
},
1817
};

src/select/optionGroup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default defineComponent({
4343
const children: ScopedSlotReturnValue = renderTNode('default');
4444
return (
4545
<li class={this.classes}>
46-
<div class={`${this.componentName}-option-group__header`}>{this.label}</div>
46+
{(this.label ?? false) && <div class={`${this.componentName}-option-group__header`}>{this.label}</div>}
4747
{children}
4848
</li>
4949
);

src/select/select-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ export default defineComponent({
270270
} & OptionsType,
271271
index,
272272
) => {
273-
if (item.group) {
273+
if (item.children) {
274274
return (
275275
<TOptionGroup label={item.group} divider={item.divider}>
276276
{this.renderOptionsContent(item.children)}

0 commit comments

Comments
 (0)