Fix input's onSubmit action being triggered if its validation is failing (#2960)

This commit is contained in:
Rishabh Saxena 2021-02-10 13:13:41 +05:30 committed by GitHub
parent 4becc50005
commit 8c72e901ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -154,10 +154,11 @@ class InputWidget extends BaseWidget<InputWidgetProps, WidgetState> {
| React.KeyboardEvent<HTMLTextAreaElement>
| React.KeyboardEvent<HTMLInputElement>,
) => {
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,