Skip to content

Commit 91669a6

Browse files
authored
Merge pull request #12963 from IgniteUI/simeonoff/fix-12894-16.0.x
fix(input): file name(s) not cleared on form reset
2 parents d6da331 + ac8680d commit 91669a6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

projects/igniteui-angular/src/lib/directives/input/input.directive.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
9999

100100
private _valid = IgxInputState.INITIAL;
101101
private _statusChanges$: Subscription;
102+
private _valueChanges$: Subscription;
102103
private _fileNames: string;
103104
private _disabled = false;
104105

@@ -305,6 +306,10 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
305306
this._statusChanges$ = this.ngControl.statusChanges.subscribe(
306307
this.onStatusChanged.bind(this)
307308
);
309+
310+
this._valueChanges$ = this.ngControl.valueChanges.subscribe(
311+
this.onValueChanged.bind(this)
312+
);
308313
}
309314

310315
this.cdr.detectChanges();
@@ -314,6 +319,10 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
314319
if (this._statusChanges$) {
315320
this._statusChanges$.unsubscribe();
316321
}
322+
323+
if (this._valueChanges$) {
324+
this._valueChanges$.unsubscribe();
325+
}
317326
}
318327
/**
319328
* Sets a focus on the igxInput.
@@ -345,6 +354,14 @@ export class IgxInputDirective implements AfterViewInit, OnDestroy {
345354
}
346355
this.updateValidityState();
347356
}
357+
358+
/** @hidden @internal */
359+
protected onValueChanged() {
360+
if (this._fileNames && !this.value) {
361+
this._fileNames = '';
362+
}
363+
}
364+
348365
/**
349366
* @hidden
350367
* @internal

0 commit comments

Comments
 (0)