0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-03-10 22:22:45 -05:00

fix(console): ignore empty number input box in connector config (#3822)

This commit is contained in:
Darcy Ye 2023-05-15 15:43:54 +08:00 committed by GitHub
parent e62b0bae5e
commit a65bc9b13b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 2 deletions

View file

@ -0,0 +1,5 @@
---
"@logto/console": patch
---
Should ignore empty number input box when parsing connector config form.

View file

@ -0,0 +1,5 @@
---
"@logto/connector-saml": patch
---
Should use placeholder instead of default value.

View file

@ -145,7 +145,7 @@ export const formItems: ConnectorConfigFormItem[] = [
type: ConnectorConfigFormItemType.Number,
label: 'Timeout',
key: 'timeout',
defaultValue: 5000,
placeholder: '5000',
},
{
type: ConnectorConfigFormItemType.Json,

View file

@ -38,8 +38,13 @@ export const parseFormConfig = (data: ConnectorFormType, formItems: ConnectorCon
}
if (formItem.type === ConnectorConfigFormItemType.Number) {
/**
* When set ReactHookForm valueAsNumber to true, the number input field
* will return number value. If the input can not be properly converted
* to number value, it will return NaN instead.
*/
// The number input my return string value.
return [key, Number(value)];
return Number.isNaN(value) ? null : [key, Number(value)];
}
if (formItem.type === ConnectorConfigFormItemType.Json) {