diff --git a/packages/velaux-ui/src/pages/ApplicationConfig/components/TraitDialog/index.tsx b/packages/velaux-ui/src/pages/ApplicationConfig/components/TraitDialog/index.tsx index cb19bfd28..92977630f 100644 --- a/packages/velaux-ui/src/pages/ApplicationConfig/components/TraitDialog/index.tsx +++ b/packages/velaux-ui/src/pages/ApplicationConfig/components/TraitDialog/index.tsx @@ -195,14 +195,28 @@ class TraitDialog extends React.Component { .then((re) => { if (re) { this.setState({ definitionDetail: re, definitionLoading: false }); - if (callback) { - callback(); - } + this.setDefaultProperties(re) + if (callback) { + callback(); + } } }) .catch(() => this.setState({ definitionLoading: false })); }; + setDefaultProperties = (definitionDetail: DefinitionDetail) => { + const properties = definitionDetail.schema?.properties; + if (properties) { + const defaultValues = {}; + for (const key in properties) { + if (properties[key].default !== undefined) { + defaultValues[key] = properties[key].default; + } + } + this.field.setValues({ properties: defaultValues }); + } + }; + handleTypeChange = (value: string) => { this.removeProperties(); this.field.setValues({ type: value });