Skip to content

Commit

Permalink
[added] react-bootstrap#1320 allow NavItem class to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
egauci committed Oct 1, 2015
1 parent 6b7bf4e commit dbb0385
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const Tabs = React.createClass({
React.PropTypes.number,
React.PropTypes.object
]),
className: React.PropTypes.string,
/**
* Render without clearfix if horizontally positioned
*/
Expand Down Expand Up @@ -271,7 +272,7 @@ const Tabs = React.createClass({
return null;
}

let { eventKey, title, disabled, onKeyDown, tabIndex = 0 } = child.props;
let { eventKey, title, disabled, onKeyDown, tabClassName, tabIndex = 0 } = child.props;
let isActive = this.getActiveKey() === eventKey;

return (
Expand All @@ -282,7 +283,8 @@ const Tabs = React.createClass({
onKeyDown={createChainedFunction(this.handleKeyDown, onKeyDown)}
eventKey={eventKey}
tabIndex={isActive ? tabIndex : -1}
disabled={disabled }>
disabled={disabled }
className={tabClassName}>
{title}
</NavItem>
);
Expand Down
4 changes: 3 additions & 1 deletion test/TabsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ describe('Tabs', () => {
let instance = ReactTestUtils.renderIntoDocument(
<Tabs activeKey={1}>
<Tab title="Tab 1" className="custom" id="pane0id" eventKey={1}>Tab 1 content</Tab>
<Tab title="Tab 2" eventKey={2}>Tab 2 content</Tab>
<Tab title="Tab 2" tabClassName="tcustom" eventKey={2}>Tab 2 content</Tab>
</Tabs>
);

let panes = ReactTestUtils.scryRenderedComponentsWithType(instance, Tab);
let navs = ReactTestUtils.scryRenderedComponentsWithType(instance, NavItem);

assert.ok(React.findDOMNode(panes[0]).className.match(/\bcustom\b/));
assert.ok(React.findDOMNode(navs[1]).className.match(/\btcustom\b/));
assert.equal(React.findDOMNode(panes[0]).id, 'pane0id');
});

Expand Down

0 comments on commit dbb0385

Please sign in to comment.