Skip to content

Commit

Permalink
Fixes #1085
Browse files Browse the repository at this point in the history
  • Loading branch information
javivelasco committed Jan 10, 2017
1 parent 519b989 commit c874616
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions components/tabs/Tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Tab extends Component {
disabled: PropTypes.bool,
hidden: PropTypes.bool,
icon: PropTypes.node,
index: PropTypes.number,
label: PropTypes.node,
onActive: PropTypes.func,
onClick: PropTypes.func,
Expand Down Expand Up @@ -40,13 +41,13 @@ class Tab extends Component {

handleClick = (event) => {
if (!this.props.disabled && this.props.onClick) {
this.props.onClick(event);
this.props.onClick(event, this.props.index);
}
};

render () {
const {
onActive, // eslint-disable-line
index, onActive, // eslint-disable-line
active, activeClassName, className, disabled, hidden, label, icon, theme, ...other
} = this.props;
const _className = classnames(theme.label, {
Expand Down
13 changes: 7 additions & 6 deletions components/tabs/Tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ const factory = (Tab, TabContent, FontIcon) => {
clearTimeout(this.resizeTimeout);
}

handleHeaderClick = (event) => {
const idx = parseInt(event.currentTarget.id);
if (this.props.onChange) this.props.onChange(idx);
handleHeaderClick = (idx) => {
if (this.props.onChange) {
this.props.onChange(idx);
}
};

handleResize = () => {
Expand Down Expand Up @@ -130,12 +131,12 @@ const factory = (Tab, TabContent, FontIcon) => {
renderHeaders (headers) {
return headers.map((item, idx) => {
return React.cloneElement(item, {
id: idx,
key: idx,
index: idx,
theme: this.props.theme,
active: this.props.index === idx,
onClick: (event) => {
this.handleHeaderClick(event);
onClick: (event, index) => {
this.handleHeaderClick(index);
item.props.onClick && item.props.onClick(event);
}
});
Expand Down

0 comments on commit c874616

Please sign in to comment.