@@ -27,12 +27,24 @@ export function PropertyReference({
2727 collapsable ? true : false ,
2828 ) ;
2929
30+ // Detect nested <PropertyReference> children so we can auto-collapse them.
31+ //
32+ // IMPORTANT: We use *reference equality* (`child.type === PropertyReference`)
33+ // rather than a name check (`child.type.name === "PropertyReference"`).
34+ // In production builds, minifiers (Terser/SWC) rename function components to
35+ // short identifiers like `s` or `a`, so `.name` comparisons silently fail and
36+ // the `collapsable` prop never propagates. Reference equality is minifier-safe
37+ // because both sides point to the same function identity after bundling.
38+ //
39+ // Known limitation: React.Children.map only walks *direct* children. A
40+ // <PropertyReference> wrapped inside a <div> (or any other element) will NOT
41+ // be detected here. Callers should nest PropertyReferences as direct
42+ // siblings, not wrapped in other elements, for auto-collapse to work.
3043 const enhancedChildren = React . Children . map ( children , ( child ) => {
31- if (
32- React . isValidElement ( child ) &&
33- ( child . type as any ) . name === "PropertyReference"
34- ) {
35- return React . cloneElement ( child , { collapsable : true } as Props ) ;
44+ if ( React . isValidElement ( child ) && child . type === PropertyReference ) {
45+ return React . cloneElement ( child as React . ReactElement < Props > , {
46+ collapsable : true ,
47+ } ) ;
3648 }
3749 return child ;
3850 } ) ;
@@ -65,7 +77,9 @@ export function PropertyReference({
6577 < div className = "flex-1 space-x-3" >
6678 { collapsable ? (
6779 < button
80+ type = "button"
6881 onClick = { ( ) => setIsCollapsed ( ! isCollapsed ) }
82+ aria-expanded = { ! isCollapsed }
6983 className = "flex gap-x-2 items-center font-mono font-semibold text-[var(--accent)]"
7084 >
7185 < span className = "text-xs" >
0 commit comments