about summary refs log tree commit diff
path: root/app/javascript/flavours/glitch/features/compose/components
diff options
context:
space:
mode:
authorThibG <thib@sitedethib.com>2019-07-06 18:18:08 +0200
committerThibaut Girka <thib@sitedethib.com>2019-07-07 14:03:12 +0200
commit64f3bc77acf2b992a189769b09427f93e7e5eb60 (patch)
tree3b6bdb1ab17291531ef79e3d919a473231709b14 /app/javascript/flavours/glitch/features/compose/components
parenta0b614f10acef03ade34cdae498b254059e1ba1d (diff)
[Glitch] Only scroll to the compose form if it's not horizontally in the viewport
Port c07cca4727041ea5a5721acbc603d4bfb45a15a6 to glitch-soc
Diffstat (limited to 'app/javascript/flavours/glitch/features/compose/components')
-rw-r--r--app/javascript/flavours/glitch/features/compose/components/compose_form.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/app/javascript/flavours/glitch/features/compose/components/compose_form.js b/app/javascript/flavours/glitch/features/compose/components/compose_form.js
index 822cfa95d..3d9002fe4 100644
--- a/app/javascript/flavours/glitch/features/compose/components/compose_form.js
+++ b/app/javascript/flavours/glitch/features/compose/components/compose_form.js
@@ -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();
+      }
     }
   }