Skip to content

Commit

Permalink
fix: nz-upload drag drop will open new tab when use firefox versions …
Browse files Browse the repository at this point in the history
…in 91 and 92
  • Loading branch information
alice.zhang committed Jan 21, 2022
1 parent c211a50 commit 024804e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions components/upload/upload.component.ts
Expand Up @@ -4,6 +4,7 @@
*/

import { Direction, Directionality } from '@angular/cdk/bidi';
import { DOCUMENT } from '@angular/common';
import {
ChangeDetectionStrategy,
ChangeDetectorRef,
Expand All @@ -22,7 +23,6 @@ import {
Inject,
ViewEncapsulation
} from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { Observable, of, Subject, Subscription, fromEvent } from 'rxjs';
import { filter, takeUntil } from 'rxjs/operators';

Expand Down Expand Up @@ -179,7 +179,7 @@ export class NzUploadComponent implements OnInit, AfterViewInit, OnChanges, OnDe
// #endregion

constructor(
private ngZone: NgZone,
private ngZone: NgZone,
@Inject(DOCUMENT) private document: Document,
private cdr: ChangeDetectorRef,
private i18n: NzI18nService,
Expand Down Expand Up @@ -352,10 +352,14 @@ export class NzUploadComponent implements OnInit, AfterViewInit, OnChanges, OnDe

ngAfterViewInit(): void {
// fix firefox drop open new tab
this.ngZone.runOutsideAngular(() => fromEvent(this.document.body, 'drop').pipe(takeUntil(this.destroy$)).subscribe((event) => {
event.preventDefault();
event.stopPropagation();
}));
this.ngZone.runOutsideAngular(() =>
fromEvent(this.document.body, 'drop')
.pipe(takeUntil(this.destroy$))
.subscribe(event => {
event.preventDefault();
event.stopPropagation();
})
);
}

ngOnChanges(): void {
Expand Down

0 comments on commit 024804e

Please sign in to comment.