Skip to content

Commit

Permalink
fix(form:array): fix invalid trackBy (#1741)
Browse files Browse the repository at this point in the history
  • Loading branch information
cipchk authored Dec 25, 2023
1 parent a46f2ee commit 3e55228
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/form/src/widgets/array/array.widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { ArrayLayoutWidget } from '../../widget';
<div nz-col class="ant-form-item-control-wrapper" [nzSpan]="ui.spanControl!" [nzOffset]="ui.offsetControl!">
<div class="ant-form-item-control" [class.has-error]="showError">
<div nz-row class="sf__array-container">
@for (i of $any(formProperty).properties; track $index) {
<ng-container *ngFor="let i of $any(formProperty).properties; let $index = index">
@if (i.visible && !i.ui.hidden) {
<div nz-col [nzSpan]="arraySpan" [attr.data-index]="$index" class="sf__array-item">
<nz-card>
Expand All @@ -59,7 +59,7 @@ import { ArrayLayoutWidget } from '../../widget';
</nz-card>
</div>
}
}
</ng-container>
</div>
@if (!ui.onlyVisual && showError) {
<div class="ant-form-explain">{{ error }}</div>
Expand Down Expand Up @@ -115,16 +115,12 @@ export class ArrayWidget extends ArrayLayoutWidget implements OnInit {
addItem(): void {
const property = this.formProperty.add({});
this.reValid();
if (this.ui.add) {
this.ui.add(property);
}
this.ui.add?.(property);
}

removeItem(index: number): void {
this.formProperty.remove(index);
this.reValid();
if (this.ui.remove) {
this.ui.remove(index);
}
this.ui.remove?.(index);
}
}

0 comments on commit 3e55228

Please sign in to comment.