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<HTMLTextAreaElement>
|
||||||
| React.KeyboardEvent<HTMLInputElement>,
|
| React.KeyboardEvent<HTMLInputElement>,
|
||||||
) => {
|
) => {
|
||||||
|
const { isValid, onSubmit } = this.props;
|
||||||
const isEnterKey = e.key === "Enter" || e.keyCode === 13;
|
const isEnterKey = e.key === "Enter" || e.keyCode === 13;
|
||||||
if (isEnterKey && this.props.onSubmit) {
|
if (isEnterKey && onSubmit && isValid) {
|
||||||
super.executeAction({
|
super.executeAction({
|
||||||
dynamicString: this.props.onSubmit,
|
dynamicString: onSubmit,
|
||||||
event: {
|
event: {
|
||||||
type: EventType.ON_SUBMIT,
|
type: EventType.ON_SUBMIT,
|
||||||
callback: this.onSubmitSuccess,
|
callback: this.onSubmitSuccess,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user