Skip to content

Commit

Permalink
Merge pull request #93 from sudowork/master
Browse files Browse the repository at this point in the history
Prevent onClick properly when controlled
  • Loading branch information
mathieudutour authored Jun 7, 2019
2 parents a4e0f24 + de29340 commit fd8220b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ const ProgressButton = createReactClass({
},

handleClick (e) {
if (this.props.controlled) {
const shouldAllowClick = (this.props.shouldAllowClickOnLoading ||
this.state.currentState !== STATE.LOADING) &&
this.state.currentState !== STATE.DISABLED
if (this.props.controlled && shouldAllowClick) {
this.props.onClick(e)
return true
}

if ((this.props.shouldAllowClickOnLoading ||
this.state.currentState !== STATE.LOADING) &&
this.state.currentState !== STATE.DISABLED
) {
if (shouldAllowClick) {
this.loading()
const ret = this.props.onClick(e)
this.handlePromise(ret)
Expand Down

0 comments on commit fd8220b

Please sign in to comment.