Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit c27b709

Browse files
committed
fix(plugins/plugin-client-common): markdown tabs may drop/misplace text near tab title
1 parent 2053a79 commit c27b709

File tree

2 files changed

+14
-5
lines changed
  • plugins/plugin-client-common/src/components/Content/Markdown

2 files changed

+14
-5
lines changed

plugins/plugin-client-common/src/components/Content/Markdown/components/tabbed.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,18 @@ class LinkableTabs extends React.PureComponent<Props, State> {
103103
className="kui--markdown-tab"
104104
title={<TabTitleText>{_.props.title}</TabTitleText>}
105105
>
106-
<Card className="kui--markdown-tab-card">{_.props && _.props.children}</Card>
106+
<Card className="kui--markdown-tab-card">
107+
<React.Fragment>{_.props && _.props.children}</React.Fragment>
108+
</Card>
107109
</Tab>
108110
))}
109111
</Tabs>
110112
)
113+
114+
// re: the <React.Fragment> wrapper around props.children; this is
115+
// to avoid Card's PatternFly impl creating a separate Markdown
116+
// component for every child. We know here that all of the children are part
117+
// of the same contiguous stretch of text.
111118
}
112119
}
113120

plugins/plugin-client-common/src/components/Content/Markdown/rehype-tabbed/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,15 @@ export default function plugin(/* options */) {
116116
position
117117
})
118118
return newChildren
119-
} else if (currentTabs.length > 0) {
120-
return addToTab(pchild)
121119
}
122120
}
123121

124-
newChildren.push(pchild)
125-
return newChildren
122+
if (currentTabs.length > 0) {
123+
return addToTab(pchild)
124+
} else {
125+
newChildren.push(pchild)
126+
return newChildren
127+
}
126128
}, [])
127129
}
128130
if (currentTabs.length > 0) {

0 commit comments

Comments
 (0)