From 63bed2b125277c5112afaaa841e73e21ba013344 Mon Sep 17 00:00:00 2001 From: Ben Biggs Date: Tue, 7 May 2019 14:19:36 -0500 Subject: [PATCH] fix(Button): change handleClick function --- react/src/lib/Button/index.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/react/src/lib/Button/index.js b/react/src/lib/Button/index.js index 5c85ce5c81..afbb311ff4 100644 --- a/react/src/lib/Button/index.js +++ b/react/src/lib/Button/index.js @@ -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'; @@ -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); @@ -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 = () => ( @@ -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, @@ -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() );