Skip to content

Commit

Permalink
Merge pull request #389 from WRidder/patch-2
Browse files Browse the repository at this point in the history
Add initialSelectedIndex property to Tabs
  • Loading branch information
hai-cea committed Mar 11, 2015
2 parents 02fd7f6 + cd98b70 commit 7bfdf6b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/src/app/components/pages/components/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ var TabsPage = React.createClass({
{
name: 'Tabs Props',
infoArray: [
{
name: 'initialSelectedIndex',
type: 'number',
header: 'optional',
desc: 'Specify initial visible tab index. Initial selected index is set by default to 0. If initialSelectedIndex is set but larger than the total amount of specified tabs, initialSelectedIndex will revert back to default'
},
{
name: 'tabWidth',
type: 'number',
Expand Down
10 changes: 8 additions & 2 deletions src/js/tabs/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ var InkBar = require('../ink-bar');
var Tabs = React.createClass({

propTypes: {
onActive: React.PropTypes.func
initialSelectedIndex: React.PropTypes.number,
onActive: React.PropTypes.func,
tabWidth: React.PropTypes.number
},

getInitialState: function(){
var selectedIndex = 0;
if (this.props.initialSelectedIndex && this.props.initialSelectedIndex < this.props.children.length) {
selectedIndex = this.props.initialSelectedIndex;
}
return {
selectedIndex: 0
selectedIndex: selectedIndex
};
},

Expand Down

0 comments on commit 7bfdf6b

Please sign in to comment.