diff --git a/src/app/components/generator/McdocRenderer.tsx b/src/app/components/generator/McdocRenderer.tsx index 34e605e7..2055e143 100644 --- a/src/app/components/generator/McdocRenderer.tsx +++ b/src/app/components/generator/McdocRenderer.tsx @@ -289,16 +289,16 @@ function UnionHead({ type, optional, node, makeEdit, ctx }: UnionHeadProps) { }) }, [type, makeEdit, ctx]) - const memberIndex = type.members.findIndex(m => quickEqualTypes(m, selectedType)) + const memberIndex = selectedType ? type.members.findIndex(m => quickEqualTypes(m, selectedType)) : -1 return <> - {(selectedType || !optional) &&
} + {selectedType &&
} > } @@ -430,6 +430,9 @@ interface UnionBodyProps extends BodyProps { } function UnionBody({ type, optional, node, makeEdit, ctx }: UnionBodyProps) { const selectedType = findSelectedMember(type, node) + if (selectedType === undefined) { + return <>> + } return
} @@ -494,7 +497,7 @@ function StructBody({ type: outerType, node, makeEdit, ctx }: StructBodyProps) { } } } - return