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 hiyuki2578 committed Oct 2, 2019
1 parent c2f3114 commit 51ca0b4
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 51ca0b4

Please sign in to comment.