Skip to content

Commit 8b24746

Browse files
fix(module:input-number): skip first setDisabledState when use with ngModel (#8933)
1 parent 573186e commit 8b24746

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

components/input-number/input-number.component.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export class NzInputNumberComponent implements OnInit, ControlValueAccessor {
208208

209209
private onChange: OnChangeType = () => {};
210210
private onTouched: OnTouchedType = () => {};
211+
private isDisabledFirstChange = true;
211212
private compactSize = inject(NZ_SPACE_COMPACT_SIZE, { optional: true });
212213
private inputRef = viewChild.required<ElementRef<HTMLInputElement>>('input');
213214
private hostRef = viewChild<ElementRef<HTMLDivElement>>('inputNumberHost');
@@ -339,7 +340,10 @@ export class NzInputNumberComponent implements OnInit, ControlValueAccessor {
339340
}
340341

341342
setDisabledState(disabled: boolean): void {
342-
this.finalDisabled.set(disabled);
343+
if (!this.isDisabledFirstChange) {
344+
this.finalDisabled.set(disabled);
345+
}
346+
this.isDisabledFirstChange = false;
343347
}
344348

345349
focus(): void {

0 commit comments

Comments
 (0)