|
4 | 4 | */
|
5 | 5 |
|
6 | 6 | import { Direction, Directionality } from '@angular/cdk/bidi';
|
| 7 | +import { DOCUMENT } from '@angular/common'; |
7 | 8 | import {
|
8 | 9 | ChangeDetectionStrategy,
|
9 | 10 | ChangeDetectorRef,
|
10 | 11 | Component,
|
11 | 12 | EventEmitter,
|
12 | 13 | Input,
|
13 | 14 | OnChanges,
|
| 15 | + AfterViewInit, |
14 | 16 | OnDestroy,
|
15 | 17 | OnInit,
|
16 | 18 | Optional,
|
17 | 19 | Output,
|
18 | 20 | TemplateRef,
|
19 | 21 | ViewChild,
|
| 22 | + NgZone, |
| 23 | + Inject, |
20 | 24 | ViewEncapsulation
|
21 | 25 | } from '@angular/core';
|
22 |
| -import { Observable, of, Subject, Subscription } from 'rxjs'; |
| 26 | +import { Observable, of, Subject, Subscription, fromEvent } from 'rxjs'; |
23 | 27 | import { filter, takeUntil } from 'rxjs/operators';
|
24 | 28 |
|
25 | 29 | import { BooleanInput, NumberInput, NzSafeAny } from 'ng-zorro-antd/core/types';
|
@@ -52,7 +56,7 @@ import { NzUploadListComponent } from './upload-list.component';
|
52 | 56 | '[class.ant-upload-picture-card-wrapper]': 'nzListType === "picture-card"'
|
53 | 57 | }
|
54 | 58 | })
|
55 |
| -export class NzUploadComponent implements OnInit, OnChanges, OnDestroy { |
| 59 | +export class NzUploadComponent implements OnInit, AfterViewInit, OnChanges, OnDestroy { |
56 | 60 | static ngAcceptInputType_nzLimit: NumberInput;
|
57 | 61 | static ngAcceptInputType_nzSize: NumberInput;
|
58 | 62 | static ngAcceptInputType_nzDirectory: BooleanInput;
|
@@ -175,6 +179,8 @@ export class NzUploadComponent implements OnInit, OnChanges, OnDestroy {
|
175 | 179 | // #endregion
|
176 | 180 |
|
177 | 181 | constructor(
|
| 182 | + private ngZone: NgZone, |
| 183 | + @Inject(DOCUMENT) private document: NzSafeAny, |
178 | 184 | private cdr: ChangeDetectorRef,
|
179 | 185 | private i18n: NzI18nService,
|
180 | 186 | @Optional() private directionality: Directionality
|
@@ -344,6 +350,18 @@ export class NzUploadComponent implements OnInit, OnChanges, OnDestroy {
|
344 | 350 | });
|
345 | 351 | }
|
346 | 352 |
|
| 353 | + ngAfterViewInit(): void { |
| 354 | + // fix firefox drop open new tab |
| 355 | + this.ngZone.runOutsideAngular(() => |
| 356 | + fromEvent<MouseEvent>(this.document.body, 'drop') |
| 357 | + .pipe(takeUntil(this.destroy$)) |
| 358 | + .subscribe(event => { |
| 359 | + event.preventDefault(); |
| 360 | + event.stopPropagation(); |
| 361 | + }) |
| 362 | + ); |
| 363 | + } |
| 364 | + |
347 | 365 | ngOnChanges(): void {
|
348 | 366 | this.zipOptions().setClassMap();
|
349 | 367 | }
|
|
0 commit comments