Skip to content

Commit 50755a4

Browse files
authored
Fix scroll position resetting when opening media modals in web UI (#11815)
1 parent 9361981 commit 50755a4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

app/javascript/mastodon/containers/mastodon.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { hydrateStore } from '../actions/store';
1212
import { connectUserStream } from '../actions/streaming';
1313
import { IntlProvider, addLocaleData } from 'react-intl';
1414
import { getLocale } from '../locales';
15+
import { previewState as previewMediaState } from 'mastodon/features/ui/components/media_modal';
16+
import { previewState as previewVideoState } from 'mastodon/features/ui/components/video_modal';
1517
import initialState from '../initial_state';
1618
import ErrorBoundary from '../components/error_boundary';
1719

@@ -35,6 +37,10 @@ class MastodonMount extends React.PureComponent {
3537
showIntroduction: PropTypes.bool,
3638
};
3739

40+
shouldUpdateScroll (_, { location }) {
41+
return location.state !== previewMediaState && location.state !== previewVideoState;
42+
}
43+
3844
render () {
3945
const { showIntroduction } = this.props;
4046

@@ -44,7 +50,7 @@ class MastodonMount extends React.PureComponent {
4450

4551
return (
4652
<BrowserRouter basename='/web'>
47-
<ScrollContext>
53+
<ScrollContext shouldUpdateScroll={this.shouldUpdateScroll}>
4854
<Route path='/' component={UI} />
4955
</ScrollContext>
5056
</BrowserRouter>

0 commit comments

Comments
 (0)