From 06c83527f5e4b7c8460f7d4a62322d2b8e805056 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Sun, 29 Jul 2018 23:52:06 +0900 Subject: Do not scroll up when modal is opened (#8095) --- app/javascript/mastodon/features/ui/index.js | 67 +++++++++++++++------------- 1 file changed, 36 insertions(+), 31 deletions(-) (limited to 'app/javascript/mastodon/features/ui/index.js') diff --git a/app/javascript/mastodon/features/ui/index.js b/app/javascript/mastodon/features/ui/index.js index 56a856230..67484fc63 100644 --- a/app/javascript/mastodon/features/ui/index.js +++ b/app/javascript/mastodon/features/ui/index.js @@ -1,12 +1,14 @@ import classNames from 'classnames'; import React from 'react'; -import NotificationsContainer from './containers/notifications_container'; +import { HotKeys } from 'react-hotkeys'; +import { defineMessages, injectIntl } from 'react-intl'; +import { connect } from 'react-redux'; +import { Redirect, withRouter } from 'react-router-dom'; import PropTypes from 'prop-types'; +import NotificationsContainer from './containers/notifications_container'; import LoadingBarContainer from './containers/loading_bar_container'; import TabsBar from './components/tabs_bar'; import ModalContainer from './containers/modal_container'; -import { connect } from 'react-redux'; -import { Redirect, withRouter } from 'react-router-dom'; import { isMobile } from '../../is_mobile'; import { debounce } from 'lodash'; import { uploadCompose, resetCompose } from '../../actions/compose'; @@ -44,9 +46,8 @@ import { PinnedStatuses, Lists, } from './util/async-components'; -import { HotKeys } from 'react-hotkeys'; import { me } from '../../initial_state'; -import { defineMessages, injectIntl } from 'react-intl'; +import { previewState } from './components/media_modal'; // Dummy import, to make sure that ends up in the application bundle. // Without this it ends up in ~8 very commonly used bundles. @@ -117,6 +118,10 @@ class SwitchingColumnsArea extends React.PureComponent { window.removeEventListener('resize', this.handleResize); } + shouldUpdateScroll (_, { location }) { + return location.state !== previewState; + } + handleResize = debounce(() => { // The cached heights are no longer accurate, invalidate this.props.onLayoutChange(); @@ -141,36 +146,36 @@ class SwitchingColumnsArea extends React.PureComponent { {redirect} - - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + -- cgit