Skip to content

Commit

Permalink
fix(Button): change handleClick function
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Biggs authored and bfbiggs committed May 7, 2019
1 parent eacce78 commit 63bed2b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions react/src/lib/Button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Loading } from '@momentum-ui/react';
import omit from 'lodash/omit';

class Button extends React.Component {
static displayName = 'Button';
Expand Down Expand Up @@ -48,9 +49,9 @@ class Button extends React.Component {
}
};

handleClick = (e, onClick) => {
handleClick = e => {
const { handleClick } = this.context;
const { index } = this.props;
const { index, onClick } = this.props;

onClick && onClick(e);
handleClick && handleClick(e, index);
Expand All @@ -74,15 +75,18 @@ class Button extends React.Component {
label,
loading,
large,
onClick,
removeStyle,
size,
style,
tag,
type,
...otherHTMLProps
...props
} = this.props;

const otherProps = omit({...props}, [
'onClick'
]);

const { focusIndex } = this.context;

const isButtonGroupIcon = () => (
Expand Down Expand Up @@ -160,7 +164,7 @@ class Button extends React.Component {
`${(removeStyle && ' md-button--none') || ''}` +
`${(active && !disabled && ` active`) || ''}` +
`${(className && ` ${className}`) || ''}`,
onClick: e => this.handleClick(e, onClick),
onClick: this.handleClick,
onKeyDown: this.handleKeyDown,
style: style,
disabled: disabled || loading,
Expand All @@ -173,7 +177,7 @@ class Button extends React.Component {
tabIndex: (typeof index !== 'number'
|| index === focusIndex) ? 0 : -1,
...tag && tag !== 'button' && {role: 'button'},
...otherHTMLProps,
...otherProps,
},
getChildren()
);
Expand Down

0 comments on commit 63bed2b

Please sign in to comment.