Skip to content

Commit 87a86e4

Browse files
matamatanotclaude
andcommitted
fix: DefinitionListでFragmentの子要素を適切に処理するよう修正
Children.toArrayとflatMapを使用してFragmentを展開し、 Fragment内のDefinitionListItemにもpropsが渡されるように改善 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent f955efd commit 87a86e4

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

packages/smarthr-ui/src/components/DefinitionList/DefinitionList.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
Children,
33
type ComponentProps,
44
type FC,
5+
Fragment,
56
type PropsWithChildren,
67
type ReactElement,
78
cloneElement,
@@ -55,15 +56,21 @@ export const DefinitionList: FC<Props & ElementProps> = ({
5556
termStyleType={termStyleType}
5657
/>
5758
))}
58-
{Children.map(
59-
children,
60-
(child) =>
61-
isValidElement(child) &&
62-
cloneElement(child as ReactElement, {
63-
maxColumns,
64-
termStyleType,
65-
}),
66-
)}
59+
{Children.toArray(children)
60+
.flatMap((child) => {
61+
if (isValidElement(child) && child.type === Fragment) {
62+
return Children.toArray(child.props.children)
63+
}
64+
return child
65+
})
66+
.map((child) =>
67+
isValidElement(child)
68+
? cloneElement(child as ReactElement, {
69+
maxColumns,
70+
termStyleType,
71+
})
72+
: child,
73+
)}
6774
</Cluster>
6875
)
6976
}

0 commit comments

Comments
 (0)