Skip to content

Commit

Permalink
fix(InteriorLeftNav): allow arbitraty child node types (carbon-design…
Browse files Browse the repository at this point in the history
  • Loading branch information
asudoh authored and marijohannessen committed Jan 29, 2018
1 parent 9d6d38c commit 0a86cb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/components/InteriorLeftNav/InteriorLeftNav-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,19 @@ describe('InteriorLeftNav', () => {
className="test-child">
<a href="http://www.carbondesignsystem.com">test-title</a>
</InteriorLeftNavItem>
<div data-child-div>foo</div>
</InteriorLeftNav>
);
expect(interiorLeftNav.find('.left-nav-list').length).toEqual(2);
expect(interiorLeftNav.find('.test-child').length).toEqual(4);
expect(
interiorLeftNav.find('.bx--interior-left-nav-collapse').length
).toEqual(1);
expect(
interiorLeftNav
.find('[data-child-div]')
.matchesElement(<div data-child-div>foo</div>)
).toBe(true);
});
});

Expand Down
10 changes: 4 additions & 6 deletions src/components/InteriorLeftNav/InteriorLeftNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,12 @@ export default class InteriorLeftNav extends Component {
} = this.props;

const newChildren = React.Children.map(children, (child, index) => {
let newChild;
if (child.type === InteriorLeftNavList) {
newChild = this.buildNewListChild(child, index);
} else {
newChild = this.buildNewItemChild(child, index);
return this.buildNewListChild(child, index);
} else if (child.type === InteriorLeftNavItem) {
return this.buildNewItemChild(child, index);
}

return newChild;
return child;
});

const classNames = classnames(
Expand Down

0 comments on commit 0a86cb1

Please sign in to comment.