Skip to content

Commit

Permalink
fix(tabs): label is not rendered correctly when children's type is fr…
Browse files Browse the repository at this point in the history
…agment (#1690)
  • Loading branch information
betavs authored Jan 6, 2025
1 parent 0df28a1 commit 17c24fe
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,19 @@ export default defineComponent({
let children: RendererNode[] = renderTNodeJSX('default');
const res: RendererNode[] = [];
const label: RendererNode[] = [];
children?.forEach((child) => {
if (child.type === Fragment) {
res.push(...child.children);
} else {
res.push(child);
}
if (child.children?.label) {
label.push(child.children.label()[0] || null);
}
});

const handler = (children: RendererNode[]) => {
children?.forEach((child) => {
if (child.type === Fragment) {
handler(child.children);
} else {
res.push(child);
}
if (child.children?.label) {
label.push(child.children.label()[0] || null);
}
});
};
handler(children);
children = res.filter((child: RendererNode) => child.type.name === `${prefix}-tab-panel`);
return children.map((item: RendererNode, index: number) => ({
...item.props,
Expand Down

0 comments on commit 17c24fe

Please sign in to comment.