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(module:upload): fix upload drag drop will open new tab in firefox 91 and 92 #7190

Merged
merged 4 commits into from
Mar 21, 2022

Conversation

small-lady
Copy link
Contributor

…91 and 92

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

[x ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Application (the showcase website) / infrastructure changes
[ ] Other... Please describe:

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?

[ ] Yes
[x ] No

Other information

@zorro-bot
Copy link

zorro-bot bot commented Jan 5, 2022

This preview will be available after the AzureCI is passed.

@codecov
Copy link

codecov bot commented Jan 5, 2022

Codecov Report

Merging #7190 (8f70d4c) into master (77db914) will decrease coverage by 0.09%.
The diff coverage is 93.48%.

❗ Current head 8f70d4c differs from pull request most recent head de308f3. Consider uploading reports for the commit de308f3 to get more accurate results

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
components/carousel/typings.ts 100.00% <ø> (ø)
components/input/input-group.component.ts 98.27% <ø> (ø)
components/message/message-container.component.ts 95.00% <ø> (-0.46%) ⬇️
components/message/message.service.ts 100.00% <ø> (ø)
components/notification/notification.service.ts 100.00% <ø> (ø)
components/code-editor/code-editor.component.ts 16.00% <14.28%> (+0.29%) ⬆️
components/button/button.component.ts 98.57% <50.00%> (ø)
...ponents/date-picker/lib/decade-header.component.ts 78.57% <50.00%> (ø)
components/icon/icon.service.ts 92.64% <50.00%> (-2.81%) ⬇️
components/table/src/table/tr-measure.component.ts 86.95% <50.00%> (+0.59%) ⬆️
... and 67 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77db914...de308f3. Read the comment docs.

Comment on lines 354 to 356
ngAfterViewInit(): void {
document.body.addEventListener('drop', this.handleDropOpenNewTab);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
document.body.removeEventListener('drop', this.handleDropOpenNewTab)

Comment on lines 332 to 337
// fix firefox drop open new tab
private handleDropOpenNewTab(e: DragEvent){
e.preventDefault();
e.stopPropagation()
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// fix firefox drop open new tab
private handleDropOpenNewTab(e: DragEvent){
e.preventDefault();
e.stopPropagation()
}

@small-lady small-lady changed the title fix: nz-upload drag drop will open new tab when use firefox versions … fix(module:upload): fix nz-upload drag drop will open new tab when use firefox versions … Jan 14, 2022
@cipchk
Copy link
Member

cipchk commented Jan 15, 2022

@small-lady Record a screen? I don't see this prompt here. My firefox env: Mac 95.0.2 (64-bit).

@small-lady
Copy link
Contributor Author

small-lady commented Jan 21, 2022

@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)

@small-lady small-lady changed the title fix(module:upload): fix nz-upload drag drop will open new tab when use firefox versions … fix(module:upload): fix upload drag drop will open new tab when use firefox 91 and 92 Jan 21, 2022
@simplejason
Copy link
Member

@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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Inject(DOCUMENT) private document: Document,
@Inject(DOCUMENT) private document: NzSafeAny,

建议使用 NzSafeAny 来代替,不然可能在 SSR 下会有问题。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cipchk 已按建议修改,谢谢~

@cipchk
Copy link
Member

cipchk commented Mar 5, 2022

LGTM

@simplejason simplejason changed the title fix(module:upload): fix upload drag drop will open new tab when use firefox 91 and 92 fix(module:upload): fix upload drag drop will open new tab in firefox 91 and 92 Mar 21, 2022
@simplejason simplejason merged commit 9b51874 into NG-ZORRO:master Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants