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: Backtop cannot work in Chrome iframe #24194

Merged
merged 1 commit into from
May 15, 2020
Merged

fix: Backtop cannot work in Chrome iframe #24194

merged 1 commit into from
May 15, 2020

Conversation

afc163
Copy link
Member

@afc163 afc163 commented May 15, 2020

[中文版模板 / Chinese template]

🤔 This is a ...

  • New feature
  • Bug fix
  • Site / documentation update
  • Demo update
  • Component style update
  • TypeScript definition update
  • Bundle size optimization
  • Perfermance optimization
  • Refactoring
  • Code style optimization
  • Test Case
  • Branch merge
  • Other (about what?)

🔗 Related issue link

close #24192

💡 Background and solution

#22788 没有修干净,Chrome 下还是不能用。

📝 Changelog

Language Changelog
🇺🇸 English Fix BackTop not working in iframe of Chrome.
🇨🇳 Chinese 修复 BackTop 在 Chrome 的 iframe 里不生效的问题。

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • TypeScript definition is updated/provided or not needed
  • Changelog is provided or not needed

Copy link

@tests-checker tests-checker bot left a comment

Choose a reason for hiding this comment

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

Could you please add tests to make sure this change works as expected?

@afc163 afc163 changed the title 🐛 Fix Backtop cannot work in Chrome iframe fix: Backtop cannot work in Chrome iframe May 15, 2020
@@ -24,8 +24,8 @@ export default function scrollTo(y: number, options: ScrollToOptions = {}) {
const nextScrollTop = easeInOutCubic(time > duration ? duration : time, scrollTop, y, duration);
if (isWindow(container)) {
(container as Window).scrollTo(window.pageXOffset, nextScrollTop);
} else if (container instanceof Document) {
container.documentElement.scrollTop = nextScrollTop;
} else if (container instanceof HTMLDocument || container.constructor.name === 'HTMLDocument') {
Copy link
Member Author

Choose a reason for hiding this comment

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

Chrome 下 element.ownerDocument instanceof HTMLDocument 是 false,比较奇怪。

Copy link
Member

Choose a reason for hiding this comment

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

image
为啥控制台是true...

Copy link
Member Author

Choose a reason for hiding this comment

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

image

image

非常诡异。

@ant-design-bot
Copy link
Contributor

ant-design-bot commented May 15, 2020

@codecov
Copy link

codecov bot commented May 15, 2020

Codecov Report

Merging #24194 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #24194   +/-   ##
=======================================
  Coverage   98.82%   98.82%           
=======================================
  Files         364      364           
  Lines        7291     7291           
  Branches     2019     1970   -49     
=======================================
  Hits         7205     7205           
  Misses         86       86           
Impacted Files Coverage Δ
components/_util/scrollTo.ts 100.00% <100.00%> (ø)

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 a83143b...41d42fb. Read the comment docs.

@afc163 afc163 merged commit 04ad723 into master May 15, 2020
@afc163 afc163 deleted the fix-back-top branch May 15, 2020 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BackTop 无效
3 participants