Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kit): InputFiles fix drag over detection when zone.js event coalescing is enabled #7031

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
};
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
Loading