From de29340070114d631ea0b067e6727946bb5e1781 Mon Sep 17 00:00:00 2001 From: Kevin Gao Date: Thu, 6 Jun 2019 18:45:39 -0700 Subject: [PATCH] Prevent onClick properly when controlled --- src/index.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/index.js b/src/index.js index f76e2ec..a873143 100644 --- a/src/index.js +++ b/src/index.js @@ -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)