Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lib/components/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,18 @@ module.exports = React.createClass({
// Keep reference to last index for event handler
const last = this.state.selectedIndex;

// Update selected index
this.setState({ selectedIndex: index, focus: focus === true });
// Check wether change event handler cancels the tab change
let cancel = false;

// Call change event handler
if (typeof this.props.onSelect === 'function') {
this.props.onSelect(index, last);
cancel = (this.props.onSelect(index, last) === false);
}

if (!cancel) {
// Update selected index
this.setState({ selectedIndex: index, focus: focus === true });
}
},

getNextTab(index) {
Expand Down