Skip to content

Commit

Permalink
fix(kit): InputFiles fix drag over detection when zone.js event coa…
Browse files Browse the repository at this point in the history
…lescing is enabled (#7031)
  • Loading branch information
hakimio authored Mar 19, 2024
1 parent 4dbe8ac commit 5b9a605
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion projects/demo/src/emulate/ng-zone-options.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const NgZoneOptionsCoalescing = {
ngZone: 'zone.js' as const,
ngZoneEventCoalescing: false,
ngZoneEventCoalescing: true,
ngZoneRunCoalescing: false,
};
7 changes: 4 additions & 3 deletions projects/kit/components/input-files/input-files.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class TuiInputFilesComponent
@ViewChild('input')
private readonly input?: ElementRef<HTMLInputElement>;

private dataTransfer: DataTransfer | null = null;
private files?: FileList | null = null;

@ContentChild(forwardRef(() => TuiInputFilesDirective))
readonly nativeInput?: TuiInputFilesDirective;
Expand Down Expand Up @@ -158,7 +158,7 @@ export class TuiInputFilesComponent
}

get fileDragged(): boolean {
return !!this.dataTransfer?.types.includes('Files');
return !!this.files && !this.computedDisabled;
}

get arrayValue(): readonly TuiFileLike[] {
Expand All @@ -185,11 +185,12 @@ export class TuiInputFilesComponent
}

onDropped(event: DataTransfer): void {
this.files = null;
this.processSelectedFiles(event.files);
}

onDragOver(dataTransfer: DataTransfer | null): void {
this.dataTransfer = dataTransfer;
this.files = dataTransfer?.files;
}

removeFile(removedFile: TuiFileLike): void {
Expand Down

0 comments on commit 5b9a605

Please sign in to comment.