-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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(module:upload): fix upload drag drop will open new tab in firefox 91 and 92 #7190
Conversation
This preview will be available after the AzureCI is passed. |
Codecov Report
@@ Coverage Diff @@
## master #7190 +/- ##
==========================================
- Coverage 91.67% 91.57% -0.10%
==========================================
Files 486 487 +1
Lines 15868 16014 +146
Branches 2587 2604 +17
==========================================
+ Hits 14547 14665 +118
- Misses 1007 1036 +29
+ Partials 314 313 -1
Continue to review full report at Codecov.
|
ngAfterViewInit(): void { | ||
document.body.addEventListener('drop', this.handleDropOpenNewTab); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ngAfterViewInit(): void { | |
document.body.addEventListener('drop', this.handleDropOpenNewTab); | |
} | |
constructor(private ngZone: NgZone, @Inject(DOCUMENT) private document: Document) {} | |
ngAfterViewInit(): void { | |
this.ngZone.runOutsideAngular(() => fromEvent(this.document.body, 'drop').pipe(takeUntil(this.destroy$)).subscribe(event => { | |
event.preventDefault(); | |
event.stopPropagation(); | |
})); | |
} |
ngOnChanges(): void { | ||
this.zipOptions().setClassMap(); | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.destroy$.next(); | ||
this.destroy$.complete(); | ||
document.body.removeEventListener('drop', this.handleDropOpenNewTab) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
document.body.removeEventListener('drop', this.handleDropOpenNewTab) |
// fix firefox drop open new tab | ||
private handleDropOpenNewTab(e: DragEvent){ | ||
e.preventDefault(); | ||
e.stopPropagation() | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// fix firefox drop open new tab | |
private handleDropOpenNewTab(e: DragEvent){ | |
e.preventDefault(); | |
e.stopPropagation() | |
} |
@small-lady Record a screen? I don't see this prompt here. My firefox env: Mac 95.0.2 (64-bit). |
This problem is not in 95.0.2 @cipchk ; it is in 91 and 92(Firefox Extended Support Release) |
@cipchk Any question about this PR? |
@@ -175,6 +179,8 @@ export class NzUploadComponent implements OnInit, OnChanges, OnDestroy { | |||
// #endregion | |||
|
|||
constructor( | |||
private ngZone: NgZone, | |||
@Inject(DOCUMENT) private document: Document, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Inject(DOCUMENT) private document: Document, | |
@Inject(DOCUMENT) private document: NzSafeAny, |
建议使用 NzSafeAny
来代替,不然可能在 SSR 下会有问题。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cipchk 已按建议修改,谢谢~
LGTM |
…91 and 92
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
解决nz-upload在火狐浏览器91及92版本上拖拽上传时会默认打开一个新窗口
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information