mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-14 02:44:13 +00:00
Fix clicking on already-opened thread post scrolling to the top of the thread (#27331)
This commit is contained in:
parent
89b48681cf
commit
c310374a2f
|
@ -607,6 +607,22 @@ class Status extends ImmutablePureComponent {
|
||||||
this.setState({ fullscreen: isFullscreen() });
|
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 () {
|
render () {
|
||||||
let ancestors, descendants;
|
let ancestors, descendants;
|
||||||
const { isLoading, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
|
const { isLoading, status, ancestorsIds, descendantsIds, intl, domain, multiColumn, pictureInPicture } = this.props;
|
||||||
|
@ -660,7 +676,7 @@ class Status extends ImmutablePureComponent {
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ScrollContainer scrollKey='thread'>
|
<ScrollContainer scrollKey='thread' shouldUpdateScroll={this.shouldUpdateScroll}>
|
||||||
<div className={classNames('scrollable', { fullscreen })} ref={this.setRef}>
|
<div className={classNames('scrollable', { fullscreen })} ref={this.setRef}>
|
||||||
{ancestors}
|
{ancestors}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue