Skip to content

Commit

Permalink
Only scroll to the compose form if it's not horizontally in the viewp…
Browse files Browse the repository at this point in the history
…ort (mastodon#11246)

Avoids jumping the scroll around vertically when giving it focus and
editing long toots.
  • Loading branch information
ClearlyClaire authored and Gargron committed Jul 6, 2019
1 parent 5924520 commit 6d51d5c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}

Expand Down

0 comments on commit 6d51d5c

Please sign in to comment.