Skip to content

Commit

Permalink
Merge pull request #611 from kiwicom/fix-fragment-in-card
Browse files Browse the repository at this point in the history
FIX: Fragment after Loading in Card
  • Loading branch information
Luděk Vepřek authored Nov 7, 2018
2 parents 6118e6b + b447a8e commit aad4322
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,18 @@ class Card extends React.Component<Props, State> {
// Jest test
return [];
}
return children[0].type.name === Loading.name && !children[0].props.loading
? children[0].props.children
: children;

if (children[0].type.name === Loading.name && !children[0].props.loading) {
if (
!Array.isArray(children[0].props.children) &&
children[0].props.children.type.toString() === React.Fragment.toString()
) {
return children[0].props.children.props.children;
}

return children[0].props.children;
}
return children;
};

isExpandableCardSection = (item: any) =>
Expand All @@ -151,7 +160,6 @@ class Card extends React.Component<Props, State> {

hasAdjustedHeader = () => {
const children = this.getChildren();

// Check if first element is Header
if (children[0] !== undefined && children[0].type.name !== CardHeader.name) {
return false;
Expand Down

0 comments on commit aad4322

Please sign in to comment.