You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
736 B

  1. import { ScrollContainer as OriginalScrollContainer } from 'react-router-scroll-4';
  2. // ScrollContainer is used to automatically scroll to the top when pushing a
  3. // new history state and remembering the scroll position when going back.
  4. // There are a few things we need to do differently, though.
  5. const defaultShouldUpdateScroll = (prevRouterProps, { location }) => {
  6. // If the change is caused by opening a modal, do not scroll to top
  7. return !(location.state?.mastodonModalKey && location.state?.mastodonModalKey !== prevRouterProps?.location?.state?.mastodonModalKey);
  8. };
  9. export default
  10. class ScrollContainer extends OriginalScrollContainer {
  11. static defaultProps = {
  12. shouldUpdateScroll: defaultShouldUpdateScroll,
  13. };
  14. }