From b7f179ab20e3bae831f1e7ed5b499ceff59ce6bd Mon Sep 17 00:00:00 2001 From: Viktor Tsvetkov <142901247+vtsvetkov-splunk@users.noreply.github.com> Date: Tue, 6 Feb 2024 12:30:47 +0100 Subject: [PATCH] fix(EntityModal): prevent Enter from submitting the form in Modal window (#1047) ## The problem Enter for a form with single input triggers the form submission. [The specification](https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#implicit-submission). The form submission was not properly handled. ## The fix - hook up on form submission by adding callback onSubmit for `
` element - prevent default behavior (sending GET with formdata in params and redirect) and proceed with our handlers (validation and sending as JSON with AJAX) ## References - https://splunk.atlassian.net/browse/ADDON-61126 - https://splunk.atlassian.net/browse/ADDON-58706 Resolves #875 --- ui/src/components/BaseFormView.tsx | 9 ++++++--- ui/src/components/ConfigurationFormView.jsx | 7 +++++-- ui/src/components/EntityModal/EntityModal.tsx | 7 ++++--- ui/src/components/EntityPage.tsx | 6 ++++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ui/src/components/BaseFormView.tsx b/ui/src/components/BaseFormView.tsx index 6c9557ca1..ccc147188 100644 --- a/ui/src/components/BaseFormView.tsx +++ b/ui/src/components/BaseFormView.tsx @@ -522,8 +522,8 @@ class BaseFormView extends PureComponent