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 <textarea> scrollHeight calculation #32292

Merged
merged 2 commits into from
Jan 29, 2021

Conversation

samouri
Copy link
Member

@samouri samouri commented Jan 29, 2021

@amp-owners-bot amp-owners-bot bot requested a review from nainar January 29, 2021 00:25
@samouri samouri requested review from caroqliu and dvoytenko and removed request for nainar January 29, 2021 00:28
// 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;
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

  1. 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.
  2. 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

Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Oops 😬 You're so right, thanks for clarifying.
  2. 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.

@kristoferbaxter kristoferbaxter merged commit f538b6c into ampproject:master Jan 29, 2021
@samouri samouri deleted the formsfix branch January 29, 2021 17:26
zaparent pushed a commit to zaparent/amphtml that referenced this pull request Jan 29, 2021
* Fix for textarea scrollHeight calculation

* only apply in Chrome
westonruter added a commit to westonruter/amphtml that referenced this pull request Jan 29, 2021
* '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)
  ...
@samouri samouri self-assigned this Feb 4, 2021
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.

textarea autoexpand does not work when padding and zoom are applied.
4 participants