From 16f348431b1f8eb034b9b2c042a12fdedce6f411 Mon Sep 17 00:00:00 2001 From: ThibG Date: Sat, 6 Jul 2019 18:18:08 +0200 Subject: [PATCH] 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. --- .../mastodon/features/compose/components/compose_form.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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(); + } } }