about summary refs log tree commit diff
path: root/app/javascript/mastodon/containers/mastodon.js
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2021-07-13 15:45:17 +0200
committerGitHub <noreply@github.com>2021-07-13 15:45:17 +0200
commitd3791cca0cd862baca19ea6c7e23ce71ac5744f6 (patch)
treefdcc322863442095e8e3a7342037f96862beb7ce /app/javascript/mastodon/containers/mastodon.js
parenta2ce7508c95f473a77d46a99fc1e090c0defadcc (diff)
Improve modal flow and back button handling (#16499)
* Refactor shouldUpdateScroll passing

So far, shouldUpdateScroll has been manually passed down from the very top of
the React component hierarchy even though it is a static function common to
all ScrollContainer instances, so replaced that with a custom class extending
ScrollContainer.

* Generalize “press back to close modal” to any modal and to public pages

* Fix boost confirmation modal closing media modal
Diffstat (limited to 'app/javascript/mastodon/containers/mastodon.js')
-rw-r--r--app/javascript/mastodon/containers/mastodon.js6
1 files changed, 2 insertions, 4 deletions
diff --git a/app/javascript/mastodon/containers/mastodon.js b/app/javascript/mastodon/containers/mastodon.js
index 513b59908..892ff1ca9 100644
--- a/app/javascript/mastodon/containers/mastodon.js
+++ b/app/javascript/mastodon/containers/mastodon.js
@@ -10,8 +10,6 @@ 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';
 
@@ -41,8 +39,8 @@ export default class Mastodon extends React.PureComponent {
     }
   }
 
-  shouldUpdateScroll (_, { location }) {
-    return location.state !== previewMediaState && location.state !== previewVideoState;
+  shouldUpdateScroll (prevRouterProps, { location }) {
+    return !(location.state?.mastodonModalKey && location.state?.mastodonModalKey !== prevRouterProps?.location?.state?.mastodonModalKey);
   }
 
   render () {