Skip to content

Commit

Permalink
fix(form): fix can't render due to inherited (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk committed Apr 16, 2023
1 parent 113c686 commit d14c866
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/form/src/model/form.property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export abstract class FormProperty {
const visibleIf = (this.ui as SFUISchemaItem).visibleIf;
if (typeof visibleIf === 'object' && Object.keys(visibleIf).length === 0) {
this.setVisible(false);
} else if (visibleIf !== undefined) {
} else if (visibleIf != null) {
const propertiesBinding: Array<Observable<boolean>> = [];
for (const dependencyPath in visibleIf) {
if (visibleIf.hasOwnProperty(dependencyPath)) {
Expand Down
11 changes: 7 additions & 4 deletions packages/form/src/sf.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,25 +324,28 @@ export class SFComponent implements OnInit, OnChanges, OnDestroy {
Object.keys(schema.properties!).forEach(key => {
const uiKey = `$${key}`;
const property = retrieveSchema(schema.properties![key] as SFSchema, definitions);
const curSetUi = deepCopy({
const curUi = deepCopy({
...(property.ui as SFUISchemaItem),
...uiSchema[uiKey]
});
const ui = deepCopy({
...this._defUi,
...parentUiSchema,
// 忽略部分会引起呈现的属性
visibleIf: undefined,
hidden: undefined,
widget: property.type,
...(property.format && (this.options.formatMap as NzSafeAny)[property.format]),
...(typeof property.ui === 'string' ? { widget: property.ui } : null),
...(!property.format && !property.ui && Array.isArray(property.enum) && property.enum.length > 0
? { widget: 'select' }
: null),
...curSetUi
}) as SFUISchemaItemRun;
...curUi
} as SFUISchemaItemRun) as SFUISchemaItemRun;
// 继承父节点布局属性
if (isHorizontal) {
if (parentUiSchema.spanLabelFixed) {
if (!curSetUi.spanLabelFixed) {
if (!curUi.spanLabelFixed) {
ui.spanLabelFixed = parentUiSchema.spanLabelFixed;
}
} else {
Expand Down

0 comments on commit d14c866

Please sign in to comment.