Skip to content

Commit 800e6f4

Browse files
authored
fix(module:input-number): fix errors before initialization (#7531)
1 parent 44d9770 commit 800e6f4

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class NzInputNumberGroupWhitSuffixOrPrefixDirective {
5757
[template]="nzAddOnBefore"
5858
></div>
5959
<div
60-
*ngIf="isAffix; else contentTemplate"
60+
*ngIf="isAffix || hasFeedback; else contentTemplate"
6161
class="ant-input-number-affix-wrapper"
6262
[class.ant-input-number-affix-wrapper-disabled]="disabled"
6363
[class.ant-input-number-affix-wrapper-sm]="isSmall"
@@ -101,6 +101,9 @@ export class NzInputNumberGroupWhitSuffixOrPrefixDirective {
101101
</ng-template>
102102
<ng-template #contentTemplate>
103103
<ng-content></ng-content>
104+
<span *ngIf="!isAddOn && !isAffix && isFeedback" nz-input-number-group-slot type="suffix">
105+
<nz-form-item-feedback-icon *ngIf="isFeedback" [status]="status"></nz-form-item-feedback-icon>
106+
</span>
104107
</ng-template>
105108
`,
106109
host: {

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
ElementRef,
1515
EventEmitter,
1616
forwardRef,
17-
Host,
1817
Input,
1918
NgZone,
2019
OnChanges,
@@ -31,7 +30,7 @@ import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
3130
import { fromEvent, merge, Subject } from 'rxjs';
3231
import { distinctUntilChanged, takeUntil } from 'rxjs/operators';
3332

34-
import { NzFormStatusService } from 'ng-zorro-antd/core/form';
33+
import { NzFormNoStatusService, NzFormStatusService } from 'ng-zorro-antd/core/form';
3534
import { NzDestroyService } from 'ng-zorro-antd/core/services';
3635
import {
3736
BooleanInput,
@@ -44,8 +43,6 @@ import {
4443
} from 'ng-zorro-antd/core/types';
4544
import { getStatusClassNames, InputBoolean, isNotNil } from 'ng-zorro-antd/core/util';
4645

47-
import { NzInputNumberGroupComponent } from './input-number-group.component';
48-
4946
@Component({
5047
selector: 'nz-input-number',
5148
exportAs: 'nzInputNumber',
@@ -90,7 +87,7 @@ import { NzInputNumberGroupComponent } from './input-number-group.component';
9087
</div>
9188
<nz-form-item-feedback-icon
9289
class="ant-input-number-suffix"
93-
*ngIf="hasFeedback && !!status && !nzInputNumberGroupComponent?.isFeedback"
90+
*ngIf="hasFeedback && !!status && !nzFormNoStatusService"
9491
[status]="status"
9592
></nz-form-item-feedback-icon>
9693
`,
@@ -406,8 +403,8 @@ export class NzInputNumberComponent implements ControlValueAccessor, AfterViewIn
406403
private renderer: Renderer2,
407404
@Optional() private directionality: Directionality,
408405
private destroy$: NzDestroyService,
409-
@Host() @Optional() public nzInputNumberGroupComponent?: NzInputNumberGroupComponent,
410-
@Optional() public nzFormStatusService?: NzFormStatusService
406+
@Optional() public nzFormStatusService?: NzFormStatusService,
407+
@Optional() public nzFormNoStatusService?: NzFormNoStatusService
411408
) {}
412409

413410
ngOnInit(): void {

components/input-number/input-number.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import { NzInputNumberComponent } from './input-number.component';
2323
imports: [BidiModule, CommonModule, FormsModule, NzOutletModule, NzIconModule, NzFormPatchModule],
2424
declarations: [
2525
NzInputNumberComponent,
26-
NzInputNumberGroupWhitSuffixOrPrefixDirective,
2726
NzInputNumberGroupComponent,
27+
NzInputNumberGroupWhitSuffixOrPrefixDirective,
2828
NzInputNumberGroupSlotComponent
2929
],
30-
exports: [NzInputNumberComponent, NzInputNumberGroupWhitSuffixOrPrefixDirective, NzInputNumberGroupComponent]
30+
exports: [NzInputNumberComponent, NzInputNumberGroupComponent, NzInputNumberGroupWhitSuffixOrPrefixDirective]
3131
})
3232
export class NzInputNumberModule {}

components/input/input-group.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class NzInputGroupWhitSuffixOrPrefixDirective {
5757
[template]="nzAddOnBefore"
5858
></span>
5959
<span
60-
*ngIf="isAffix; else contentTemplate"
60+
*ngIf="isAffix || hasFeedback; else contentTemplate"
6161
class="ant-input-affix-wrapper"
6262
[class.ant-input-affix-wrapper-disabled]="disabled"
6363
[class.ant-input-affix-wrapper-sm]="isSmall"
@@ -101,6 +101,9 @@ export class NzInputGroupWhitSuffixOrPrefixDirective {
101101
</ng-template>
102102
<ng-template #contentTemplate>
103103
<ng-content></ng-content>
104+
<span *ngIf="!isAddOn && !isAffix && isFeedback" nz-input-group-slot type="suffix">
105+
<nz-form-item-feedback-icon [status]="status"></nz-form-item-feedback-icon>
106+
</span>
104107
</ng-template>
105108
`,
106109
host: {

components/input/input.directive.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
ComponentRef,
99
Directive,
1010
ElementRef,
11-
Host,
1211
Input,
1312
OnChanges,
1413
OnDestroy,
@@ -23,12 +22,10 @@ import { NgControl } from '@angular/forms';
2322
import { Subject } from 'rxjs';
2423
import { distinctUntilChanged, filter, takeUntil } from 'rxjs/operators';
2524

26-
import { NzFormItemFeedbackIconComponent, NzFormStatusService } from 'ng-zorro-antd/core/form';
25+
import { NzFormItemFeedbackIconComponent, NzFormNoStatusService, NzFormStatusService } from 'ng-zorro-antd/core/form';
2726
import { BooleanInput, NgClassInterface, NzSizeLDSType, NzStatus, NzValidateStatus } from 'ng-zorro-antd/core/types';
2827
import { getStatusClassNames, InputBoolean } from 'ng-zorro-antd/core/util';
2928

30-
import { NzInputGroupComponent } from './input-group.component';
31-
3229
@Directive({
3330
selector: 'input[nz-input],textarea[nz-input]',
3431
exportAs: 'nzInput',
@@ -75,8 +72,8 @@ export class NzInputDirective implements OnChanges, OnInit, OnDestroy {
7572
private elementRef: ElementRef,
7673
protected hostView: ViewContainerRef,
7774
@Optional() private directionality: Directionality,
78-
@Host() @Optional() private nzInputGroupComponent?: NzInputGroupComponent,
79-
@Optional() private nzFormStatusService?: NzFormStatusService
75+
@Optional() private nzFormStatusService?: NzFormStatusService,
76+
@Optional() public nzFormNoStatusService?: NzFormNoStatusService
8077
) {
8178
renderer.addClass(elementRef.nativeElement, 'ant-input');
8279
}
@@ -142,7 +139,7 @@ export class NzInputDirective implements OnChanges, OnInit, OnDestroy {
142139
}
143140

144141
private renderFeedbackIcon(): void {
145-
if (!this.status || !this.hasFeedback || this.nzInputGroupComponent?.isFeedback) {
142+
if (!this.status || !this.hasFeedback || !!this.nzFormNoStatusService) {
146143
// remove feedback
147144
this.hostView.clear();
148145
this.feedbackRef = null;

0 commit comments

Comments
 (0)