Skip to content

Commit

Permalink
fix(core): prevent potential for infinite loop when two file uploader…
Browse files Browse the repository at this point in the history
…s have the same ngModel
  • Loading branch information
mikerodonnell89 committed Oct 24, 2024
1 parent ad20842 commit c7bf8a7
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions libs/core/file-uploader/file-uploader.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ export class FileUploaderComponent implements ControlValueAccessor, OnDestroy, F

/** @hidden */
writeValue(files: File[]): void {
if (files && files.length === 0) {
if (this.validFiles.length > 0 && files && files.length === 0) {
this.clear();
} else if (this._isEmpty()) {
return;
} else {
this._propagateFiles();
this._propagateFiles(false);
}
}

Expand Down Expand Up @@ -288,9 +288,11 @@ export class FileUploaderComponent implements ControlValueAccessor, OnDestroy, F
}

/** @hidden */
private _propagateFiles(): void {
private _propagateFiles(handleOnChange: boolean = true): void {
this.setInputValue(this.validFiles);
this.onChange(this.validFiles);
if (handleOnChange) {
this.onChange(this.validFiles);
}
this.selectedFilesChanged.emit(this.validFiles);
this.selectedInvalidFiles.emit(this.invalidFiles);
}
Expand Down

0 comments on commit c7bf8a7

Please sign in to comment.