Skip to content

Commit 1a4ae1d

Browse files
committed
[fixed] Fix rendering Navbar header when toggleNavKey is 0
Fixes react-bootstrap#415
1 parent 1ed8d50 commit 1a4ae1d

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/Navbar.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ var Navbar = React.createClass({
7575
return (
7676
<ComponentClass {...this.props} className={joinClasses(this.props.className, classSet(classes))}>
7777
<div className={this.props.fluid ? 'container-fluid' : 'container'}>
78-
{(this.props.brand || this.props.toggleButton || this.props.toggleNavKey) ? this.renderHeader() : null}
78+
{(this.props.brand || this.props.toggleButton || this.props.toggleNavKey != null) ? this.renderHeader() : null}
7979
{ValidComponentChildren.map(this.props.children, this.renderChild)}
8080
</div>
8181
</ComponentClass>

test/NavbarSpec.jsx

+26
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,30 @@ describe('Nav', function () {
124124
assert.equal(navNode.nodeName, 'UL');
125125
assert.equal(navNode.parentNode.nodeName, 'DIV');
126126
});
127+
128+
it('Should add header when toggleNavKey is 0', function () {
129+
var instance = ReactTestUtils.renderIntoDocument(
130+
<Navbar toggleNavKey={0}>
131+
<Nav eventKey={0}>
132+
</Nav>
133+
</Navbar>
134+
);
135+
136+
var header = ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'navbar-header');
137+
138+
assert.ok(header);
139+
});
140+
141+
it('Should add header when toggleNavKey is 1', function () {
142+
var instance = ReactTestUtils.renderIntoDocument(
143+
<Navbar toggleNavKey={1}>
144+
<Nav eventKey={1}>
145+
</Nav>
146+
</Navbar>
147+
);
148+
149+
var header = ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'navbar-header');
150+
151+
assert.ok(header);
152+
});
127153
});

0 commit comments

Comments
 (0)