Skip to content

Commit

Permalink
Prevent onClick properly when controlled
Browse files Browse the repository at this point in the history
  • Loading branch information
sudowork committed Jun 7, 2019
1 parent a4e0f24 commit de29340
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 de29340

Please sign in to comment.