Skip to content

Commit

Permalink
fix some complexity issues
Browse files Browse the repository at this point in the history
  • Loading branch information
janechu committed May 24, 2018
1 parent 395d0ad commit 4846466
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions packages/fast-development-site-react/src/components/site/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,9 @@ class Site extends React.Component<ISiteProps & IManagedClasses<ISiteManagedClas
const tocItems: any[] = Array.isArray(items) ? items : [items];

tocItems.forEach((item: JSX.Element) => {
if (item && item.props && item.props.slot === slot && ((collapsed && this.renderTocItemCategoryIcon(item)) || !collapsed)) {
const isInSlot: boolean = item && item.props && item.props.slot === slot;

if (isInSlot && ((collapsed && this.renderTocItemCategoryIcon(item)) || !collapsed)) {
categoryItems.push(item);
}
});
Expand Down Expand Up @@ -718,21 +720,15 @@ class Site extends React.Component<ISiteProps & IManagedClasses<ISiteManagedClas
const detailDocumentationSlot: string = ComponentViewSlot.detailDocumentation;

if (item.props.children) {
if (Array.isArray(item.props.children)) {
item.props.children.forEach((child: JSX.Element): void => {
hasCanvasContent = child && child.props
? child.props.slot === exampleSlot
|| child.props.slot === detailExampleSlot
|| child.props.slot === detailDocumentationSlot
: false;
});
} else {
hasCanvasContent = item.props.children.props
&& (item.props.children.props.slot === exampleSlot
|| item.props.children.props.slot === detailExampleSlot
|| item.props.children.props.slot === detailDocumentationSlot
);
}
const itemChildren: JSX.Element[] = Array.isArray(item.props.children) ? item.props.children : [item.props.children];

itemChildren.forEach((child: JSX.Element): void => {
hasCanvasContent = child && child.props
? child.props.slot === exampleSlot
|| child.props.slot === detailExampleSlot
|| child.props.slot === detailDocumentationSlot
: false;
});
}

return hasCanvasContent;
Expand Down

0 comments on commit 4846466

Please sign in to comment.