From 8c72e901ee8fbb526adb83edc93059dced510e2d Mon Sep 17 00:00:00 2001 From: Rishabh Saxena Date: Wed, 10 Feb 2021 13:13:41 +0530 Subject: [PATCH] Fix input's onSubmit action being triggered if its validation is failing (#2960) --- app/client/src/widgets/InputWidget.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/client/src/widgets/InputWidget.tsx b/app/client/src/widgets/InputWidget.tsx index 4388ec1122..1957c0dbcd 100644 --- a/app/client/src/widgets/InputWidget.tsx +++ b/app/client/src/widgets/InputWidget.tsx @@ -154,10 +154,11 @@ class InputWidget extends BaseWidget { | React.KeyboardEvent | React.KeyboardEvent, ) => { + const { isValid, onSubmit } = this.props; const isEnterKey = e.key === "Enter" || e.keyCode === 13; - if (isEnterKey && this.props.onSubmit) { + if (isEnterKey && onSubmit && isValid) { super.executeAction({ - dynamicString: this.props.onSubmit, + dynamicString: onSubmit, event: { type: EventType.ON_SUBMIT, callback: this.onSubmitSuccess,