Skip to content

Commit

Permalink
Fix clicking on already-loaded thread scrolling to the top of the thr…
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire authored Oct 9, 2023
1 parent 774e118 commit 4c2aca7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions app/javascript/mastodon/features/status/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ class Status extends ImmutablePureComponent {

componentDidMount () {
attachFullscreenListener(this.onFullScreenChange);

this._scrollStatusIntoView();
}

UNSAFE_componentWillReceiveProps (nextProps) {
Expand Down Expand Up @@ -579,10 +581,10 @@ class Status extends ImmutablePureComponent {
this.node = c;
};

componentDidUpdate (prevProps) {
const { status, ancestorsIds, multiColumn } = this.props;
_scrollStatusIntoView () {
const { status, multiColumn } = this.props;

if (status && (ancestorsIds.size > prevProps.ancestorsIds.size || prevProps.status?.get('id') !== status.get('id'))) {
if (status) {
window.requestAnimationFrame(() => {
this.node?.querySelector('.detailed-status__wrapper')?.scrollIntoView(true);

Expand All @@ -599,6 +601,14 @@ class Status extends ImmutablePureComponent {
}
}

componentDidUpdate (prevProps) {
const { status, ancestorsIds } = this.props;

if (status && (ancestorsIds.size > prevProps.ancestorsIds.size || prevProps.status?.get('id') !== status.get('id'))) {
this._scrollStatusIntoView();
}
}

componentWillUnmount () {
detachFullscreenListener(this.onFullScreenChange);
}
Expand Down

0 comments on commit 4c2aca7

Please sign in to comment.