Skip to content

Commit 66a8344

Browse files
authored
fix(withWebComponent): fix handling of react fragments as slots (#446)
1 parent a7ffcd6 commit 66a8344

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

packages/main/src/internal/withWebComponent.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ export const withWebComponent = <T extends {}>(
7070
return Object.entries(rest)
7171
.filter(([slotName]) => slotProperties.includes(slotName))
7272
.map(([slotName, slotValue]) => {
73-
return Children.map(slotValue, (item: ReactElement, index) =>
74-
cloneElement(item, {
75-
key: `${slotName}-${index}`,
76-
slot: slotName
77-
})
73+
return Children.map(
74+
slotValue?.type === React.Fragment ? slotValue.props.children : slotValue,
75+
(item: ReactElement, index) =>
76+
cloneElement(item, {
77+
key: `${slotName}-${index}`,
78+
slot: slotName
79+
})
7880
);
7981
});
8082
},

packages/main/src/webComponents/Table/Table.stories.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,15 @@ export const generatedDefaultStory = () => (
2525
<TableColumn style={{ width: '12rem' }}>
2626
<Label>Product</Label>
2727
</TableColumn>
28-
2928
<TableColumn minWidth={800} popinText="Supplier">
3029
<Label>Supplier</Label>
3130
</TableColumn>
32-
3331
<TableColumn minWidth={600} popinText="Dimensions" demandPopin>
3432
<Label>Dimensions</Label>
3533
</TableColumn>
36-
3734
<TableColumn minWidth={600} popinText="Weight" demandPopin>
3835
<Label>Weight</Label>
3936
</TableColumn>
40-
4137
<TableColumn>
4238
<Label>Price</Label>
4339
</TableColumn>

0 commit comments

Comments
 (0)