Skip to content

Commit 5d836e3

Browse files
authored
perf(select): support rendering children when group title is not exist (#3445)
1 parent c7088a0 commit 5d836e3

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
@@ -50,7 +50,7 @@ export default function useSelectOptions(
5050
dynamicIndex += 1;
5151
return res;
5252
};
53-
if ((option as SelectOptionGroup).group && (option as SelectOptionGroup).children) {
53+
if ((option as SelectOptionGroup).children) {
5454
return {
5555
...option,
5656
children: (option as SelectOptionGroup).children.map((child) => getFormatOption(child)),
@@ -124,7 +124,7 @@ export default function useSelectOptions(
124124
const res: TdOptionProps[] = [];
125125
const getOptionsList = (options: TdOptionProps[]) => {
126126
options.forEach((option) => {
127-
if ((option as SelectOptionGroup).group) {
127+
if ((option as SelectOptionGroup).children) {
128128
getOptionsList((option as SelectOptionGroup).children);
129129
} else {
130130
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
@@ -44,7 +44,7 @@ export default defineComponent({
4444
const children: ScopedSlotReturnValue = renderTNode('default');
4545
return (
4646
<li class={this.classes}>
47-
<div class={`${this.componentName}-option-group__header`}>{this.label}</div>
47+
{(this.label ?? false) && <div class={`${this.componentName}-option-group__header`}>{this.label}</div>}
4848
{children}
4949
</li>
5050
);

src/select/select-panel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ export default defineComponent({
269269
} & OptionsType,
270270
index,
271271
) => {
272-
if (item.group) {
272+
if (item.children) {
273273
return (
274274
<t-option-group label={item.group} divider={item.divider}>
275275
{this.renderOptionsContent(item.children)}

0 commit comments

Comments
 (0)