diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-07-13 12:40:15 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2021-07-13 12:51:06 +0200 |
commit | 84fbe4d030e3176fffaf49ac8eec0c0602b1ba87 (patch) | |
tree | 1db54ddae0b3379d4a776820b831d75a9747cc83 /app/javascript/flavours/glitch/containers | |
parent | 99f28c17dea35d0eec90a74c5fe95f60b6ad2f9e (diff) |
Refactor shouldUpdateScroll stuff
Diffstat (limited to 'app/javascript/flavours/glitch/containers')
-rw-r--r-- | app/javascript/flavours/glitch/containers/scroll_container.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/javascript/flavours/glitch/containers/scroll_container.js b/app/javascript/flavours/glitch/containers/scroll_container.js new file mode 100644 index 000000000..595f3155f --- /dev/null +++ b/app/javascript/flavours/glitch/containers/scroll_container.js @@ -0,0 +1,15 @@ +import { ScrollContainer as OriginalScrollContainer } from 'react-router-scroll-4'; + +// ScrollContainer is used to automatically scroll to the top when pushing a +// new history state and remembering the scroll position when going back. +// There are a few things we need to do differently, though. +const defaultShouldUpdateScroll = (prevRouterProps, { location }) => { + return !(prevRouterProps?.location?.state?.mastodonModalKey || location.state?.mastodonModalKey); +} + +export default +class ScrollContainer extends OriginalScrollContainer { + static defaultProps = { + shouldUpdateScroll: defaultShouldUpdateScroll, + }; +} |