about summary refs log tree commit diff
path: root/app/javascript
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-07-06 18:18:08 +0200
committerEugen Rochko <eugen@zeonfederated.com>2019-07-06 18:18:08 +0200
commitc07cca4727041ea5a5721acbc603d4bfb45a15a6 (patch)
tree76cd0067b59fa9258938e13c87a2d9055c8f8632 /app/javascript
parentae003d54f956fa2cbb422b04519b3a3e602652c3 (diff)
Only scroll to the compose form if it's not horizontally in the viewport (#11246)
Avoids jumping the scroll around vertically when giving it focus and
editing long toots.
Diffstat (limited to 'app/javascript')
-rw-r--r--app/javascript/mastodon/features/compose/components/compose_form.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/javascript/mastodon/features/compose/components/compose_form.js b/app/javascript/mastodon/features/compose/components/compose_form.js
index 1f476397f..47e189251 100644
--- a/app/javascript/mastodon/features/compose/components/compose_form.js
+++ b/app/javascript/mastodon/features/compose/components/compose_form.js
@@ -117,7 +117,10 @@ class ComposeForm extends ImmutablePureComponent {
 
   handleFocus = () => {
     if (this.composeForm && !this.props.singleColumn) {
-      this.composeForm.scrollIntoView();
+      const { left, right } = this.composeForm.getBoundingClientRect();
+      if (left < 0 || right > (window.innerWidth || document.documentElement.clientWidth)) {
+        this.composeForm.scrollIntoView();
+      }
     }
   }