-
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 <textarea> scrollHeight calculation #32292
Conversation
// It makes the scrollHeight calculation off by ~1px. | ||
// This is why we have a small error margin. | ||
// TODO: Remove error margin when chrome bug is resolved (https://bugs.chromium.org/p/chromium/issues/detail?id=1171989). | ||
const errorMargin = /google/i.test(win.navigator.vendor) ? 3 : 0; |
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.
Is win
preferred to this.win_
here? And should we also be checking if the document is zoomed at all?
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.
- We don't have access to this.win and it isn't a property of the textarea element either (not an AMP Component). win is already calculated earlier in the function, so it is better than writing element.ownerDocument.defaultView again.
- tabs.getZoom() would returns a Promise and I think would do the trick. My fear is that zoom isn't the root cause and it is really related to device pixel ratio - zoom is just the easiest repro method. Due to not understanding the underlying Chrome bug well enough, I'd rather stay on the safe side! WDYT
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.
- Oops 😬 You're so right, thanks for clarifying.
- It should be fine to keep. I don't foresee anything harmful happening because in the case where the bug is not present, and we are "overeager" to resize, the error margin doesn't actually factor into the given height.
* Fix for textarea scrollHeight calculation * only apply in Chrome
* 'master' of github.com:ampproject/amphtml: (1020 commits) 🏗 Clean up CI config files (ampproject#32303) 🏗 Remove Browser Installation from CI tasks and use smaller instances when possible (ampproject#32310) Cleanup fie-resources experiment (ampproject#32226) 🏗 Fix bug in build target discovery logic (ampproject#32307) 📖 Update TOC on TESTING.md (ampproject#32304) 🏗 Reorganize browserify caching code (ampproject#32297) Fix <textarea> scrollHeight calculation (ampproject#32292) 📖 Update testing docs (ampproject#32298) Fix missing space and mention `https` (ampproject#32293) ✨ [Story auto-analytics] Added validation and tests (ampproject#32288) 🏗 Consolidate remaining CircleCI VM setup steps into separate scripts (ampproject#32290) 🏗 Cache Karma's babel transforms during CircleCI builds (ampproject#32295) Add validation rules for aspect-ratio support via SSR (ampproject#32262) bump up viewer-messaging version (ampproject#32286) 🖍🚀 Alternate `position: fixed/absolute` when docking/undocking (ampproject#32243) ✨ [Panning media] Transition siblings by ID (ampproject#32217) 📦 Update dependency watchify to v4 (ampproject#32284) 📦 Update dependency rollup to v2.38.1 (ampproject#32274) 🐛♻️ ADS: XHRs race condtion and responsivnes fix (ampproject#32271) Add support for gdpr_conseented_providers, useCCPA_USPAPI, and _fw_us_privacy (ampproject#32275) ...
Fixes #32291 and
b/150231440
Related: https://bugs.chromium.org/p/chromium/issues/detail?id=1171989