about summary refs log tree commit diff
path: root/app/javascript/mastodon/containers/mastodon.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-09-12 20:14:59 +0200
committerGitHub <noreply@github.com>2019-09-12 20:14:59 +0200
commit50755a47b4f0999f8c49501ff4fa4c2ef676fa0e (patch)
tree3cc7e7b4333bd66c7b41f09ef4325112d0c40807 /app/javascript/mastodon/containers/mastodon.js
parent9361981388ed372b0502aec7d74fee9cacb4cf86 (diff)
Fix scroll position resetting when opening media modals in web UI (#11815)
Diffstat (limited to 'app/javascript/mastodon/containers/mastodon.js')
-rw-r--r--app/javascript/mastodon/containers/mastodon.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/javascript/mastodon/containers/mastodon.js b/app/javascript/mastodon/containers/mastodon.js
index 542b68282..3ac58cf7c 100644
--- a/app/javascript/mastodon/containers/mastodon.js
+++ b/app/javascript/mastodon/containers/mastodon.js
@@ -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';
 
@@ -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;
 
@@ -44,7 +50,7 @@ class MastodonMount extends React.PureComponent {
 
     return (
       <BrowserRouter basename='/web'>
-        <ScrollContext>
+        <ScrollContext shouldUpdateScroll={this.shouldUpdateScroll}>
           <Route path='/' component={UI} />
         </ScrollContext>
       </BrowserRouter>