Skip to content

Commit

Permalink
Add initialSelectedIndex property to Tabs
Browse files Browse the repository at this point in the history
Fixes mui#375. Also checks whether the index is not out of bounds w.r.t. the amount of tab children.
  • Loading branch information
WRidder committed Mar 5, 2015
1 parent 03c1691 commit c3c5296
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/js/tabs/tabs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ var Tabs = React.createClass({
},

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 c3c5296

Please sign in to comment.