Skip to content

Commit

Permalink
Fix scroll position resetting when opening media modals in web UI (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored Sep 12, 2019
1 parent 9361981 commit 50755a4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/javascript/mastodon/containers/mastodon.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { hydrateStore } from '../actions/store';
import { connectUserStream } from '../actions/streaming';
import { IntlProvider, addLocaleData } from 'react-intl';
import { getLocale } from '../locales';
import { previewState as previewMediaState } from 'mastodon/features/ui/components/media_modal';
import { previewState as previewVideoState } from 'mastodon/features/ui/components/video_modal';
import initialState from '../initial_state';
import ErrorBoundary from '../components/error_boundary';

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

shouldUpdateScroll (_, { location }) {
return location.state !== previewMediaState && location.state !== previewVideoState;
}

render () {
const { showIntroduction } = this.props;

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

return (
<BrowserRouter basename='/web'>
<ScrollContext>
<ScrollContext shouldUpdateScroll={this.shouldUpdateScroll}>
<Route path='/' component={UI} />
</ScrollContext>
</BrowserRouter>
Expand Down

0 comments on commit 50755a4

Please sign in to comment.