fix: settingField items is empty when type is not 'group'

This commit is contained in:
mario.gk 2020-07-21 09:48:09 +08:00
parent 760e6a6226
commit 582c41a121
2 changed files with 10 additions and 4 deletions

View File

@ -51,10 +51,15 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
this._expanded = extraProps?.defaultCollapsed ? false : true;
// initial items
if (this.type === 'group' && items) {
if (items && items.length > 0) {
this.initItems(items, settingFieldCollector);
} else if (settingFieldCollector && config.name) {
settingFieldCollector(config.name, this);
}
if (settingFieldCollector && config.name) {
if (parent && parent instanceof SettingField && parent.type !== 'group') {
settingFieldCollector((parent as SettingField).name + '.' + config.name, this);
} else {
settingFieldCollector(config.name, this);
}
}
// compatiable old config

View File

@ -268,8 +268,9 @@ export function upgradePropConfig(config: OldPropConfig, collector: ConfigCollec
extraProps.condition = (field: Field) => !(isHidden(field) || isDisabled(field));
}
newConfig.items = items ? upgradeConfigure(items, collector) : [];
if (type === 'group') {
newConfig.items = items ? upgradeConfigure(items, collector) : [];
return newConfig;
}