]> cat aescling's git repositories - mastodon.git/commitdiff
[Glitch] Only scroll to the compose form if it's not horizontally in the viewport
authorThibG <thib@sitedethib.com>
Sat, 6 Jul 2019 16:18:08 +0000 (18:18 +0200)
committerThibaut Girka <thib@sitedethib.com>
Sun, 7 Jul 2019 12:03:12 +0000 (14:03 +0200)
Port c07cca4727041ea5a5721acbc603d4bfb45a15a6 to glitch-soc

app/javascript/flavours/glitch/features/compose/components/compose_form.js

index 822cfa95dfa5e72c60abab30d8f5a76957c49f90..3d9002fe48772027419753a42f88fc9ad3e0e7c8 100644 (file)
@@ -197,7 +197,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();
+      }
     }
   }