@@ -87,6 +87,10 @@ export function getActionType(): ActionTypeModel {
8787const ServiceNowConnectorFields : React . FunctionComponent < ActionConnectorFieldsProps <
8888 ServiceNowActionConnector
8989> > = ( { action, editActionConfig, editActionSecrets, errors } ) => {
90+ /* We do not provide defaults values to the fields (like empty string for apiUrl) intentionally.
91+ * If we do, errors will be shown the first time the flyout is open even though the user did not
92+ * interact with the form. Also, we would like to show errors for empty fields provided by the user.
93+ /*/
9094 const { apiUrl, casesConfiguration : { mapping = [ ] } = { } } = action . config ;
9195 const { username, password } = action . secrets ;
9296
@@ -153,7 +157,7 @@ const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsPr
153157 fullWidth
154158 isInvalid = { isApiUrlInvalid }
155159 name = "apiUrl"
156- value = { apiUrl || '' }
160+ value = { apiUrl || '' } // Needed to prevent uncontrolled input error when value is undefined
157161 data-test-subj = "apiUrlFromInput"
158162 placeholder = "https://<instance>.service-now.com"
159163 onChange = { handleOnChangeActionConfig . bind ( null , 'apiUrl' ) }
@@ -175,7 +179,7 @@ const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsPr
175179 fullWidth
176180 isInvalid = { isUsernameInvalid }
177181 name = "username"
178- value = { username || '' }
182+ value = { username || '' } // Needed to prevent uncontrolled input error when value is undefined
179183 data-test-subj = "usernameFromInput"
180184 onChange = { handleOnChangeSecretConfig . bind ( null , 'username' ) }
181185 onBlur = { handleOnBlurSecretConfig . bind ( null , 'username' ) }
@@ -196,7 +200,7 @@ const ServiceNowConnectorFields: React.FunctionComponent<ActionConnectorFieldsPr
196200 fullWidth
197201 isInvalid = { isPasswordInvalid }
198202 name = "password"
199- value = { password || '' }
203+ value = { password || '' } // Needed to prevent uncontrolled input error when value is undefined
200204 data-test-subj = "passwordFromInput"
201205 onChange = { handleOnChangeSecretConfig . bind ( null , 'password' ) }
202206 onBlur = { handleOnBlurSecretConfig . bind ( null , 'password' ) }
0 commit comments