diff --git a/app/javascript/mastodon/features/status/index.jsx b/app/javascript/mastodon/features/status/index.jsx index 799354d18..482323e08 100644 --- a/app/javascript/mastodon/features/status/index.jsx +++ b/app/javascript/mastodon/features/status/index.jsx @@ -607,6 +607,22 @@ class Status extends ImmutablePureComponent { this.setState({ fullscreen: isFullscreen() }); }; + shouldUpdateScroll = (prevRouterProps, { location }) => { + // Do not change scroll when opening a modal + if (location.state?.mastodonModalKey && location.state?.mastodonModalKey !== prevRouterProps?.location?.state?.mastodonModalKey) { + return false; + } + + // Scroll to focused post if it is loaded + const child = this.node?.querySelector('.detailed-status__wrapper'); + if (child) { + return [0, child.offsetTop]; + } + + // Do not scroll otherwise, `componentDidUpdate` will take care of that + return false; + }; + render () { let ancestors, descendants; const { isLoading, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props; @@ -660,7 +676,7 @@ class Status extends ImmutablePureComponent { )} /> - +
{ancestors}