~cytrogen/masto-fe

c07cca4727041ea5a5721acbc603d4bfb45a15a6 — ThibG 6 years ago ae003d5
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.
1 files changed, 4 insertions(+), 1 deletions(-)

M app/javascript/mastodon/features/compose/components/compose_form.js
M app/javascript/mastodon/features/compose/components/compose_form.js => app/javascript/mastodon/features/compose/components/compose_form.js +4 -1
@@ 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();
      }
    }
  }