Fix input's onSubmit action being triggered if its validation is failing (#2960)
This commit is contained in:
parent
4becc50005
commit
8c72e901ee
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user