From 5452af2188ba65c9f934280b65a2040c8cc9e718 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 23 Oct 2022 23:37:58 +0200 Subject: [PATCH] Fix redirecting to `/publish` when compose form is visible in web UI (#19427) --- .../mastodon/features/compose/index.js | 30 +++++++------------ .../features/ui/components/compose_panel.js | 18 +++++++++-- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/app/javascript/mastodon/features/compose/index.js b/app/javascript/mastodon/features/compose/index.js index 763c715de8b..f744fc61155 100644 --- a/app/javascript/mastodon/features/compose/index.js +++ b/app/javascript/mastodon/features/compose/index.js @@ -4,14 +4,13 @@ import NavigationContainer from './containers/navigation_container'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { connect } from 'react-redux'; -import { mountCompose, unmountCompose } from '../../actions/compose'; +import { changeComposing, mountCompose, unmountCompose } from '../../actions/compose'; import { Link } from 'react-router-dom'; import { injectIntl, defineMessages } from 'react-intl'; import SearchContainer from './containers/search_container'; import Motion from '../ui/util/optional_motion'; import spring from 'react-motion/lib/spring'; import SearchResultsContainer from './containers/search_results_container'; -import { changeComposing } from '../../actions/compose'; import { openModal } from 'mastodon/actions/modal'; import elephantUIPlane from '../../../images/elephant_ui_plane.svg'; import { mascot } from '../../initial_state'; @@ -35,7 +34,7 @@ const messages = defineMessages({ const mapStateToProps = (state, ownProps) => ({ columns: state.getIn(['settings', 'columns']), - showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : ownProps.isSearchPage, + showSearch: ownProps.multiColumn ? state.getIn(['search', 'submitted']) && !state.getIn(['search', 'hidden']) : false, }); export default @connect(mapStateToProps) @@ -47,24 +46,17 @@ class Compose extends React.PureComponent { columns: ImmutablePropTypes.list.isRequired, multiColumn: PropTypes.bool, showSearch: PropTypes.bool, - isSearchPage: PropTypes.bool, intl: PropTypes.object.isRequired, }; componentDidMount () { - const { isSearchPage } = this.props; - - if (!isSearchPage) { - this.props.dispatch(mountCompose()); - } + const { dispatch } = this.props; + dispatch(mountCompose()); } componentWillUnmount () { - const { isSearchPage } = this.props; - - if (!isSearchPage) { - this.props.dispatch(unmountCompose()); - } + const { dispatch } = this.props; + dispatch(unmountCompose()); } handleLogoutClick = e => { @@ -92,7 +84,7 @@ class Compose extends React.PureComponent { } render () { - const { multiColumn, showSearch, isSearchPage, intl } = this.props; + const { multiColumn, showSearch, intl } = this.props; if (multiColumn) { const { columns } = this.props; @@ -117,10 +109,10 @@ class Compose extends React.PureComponent { - {(multiColumn || isSearchPage) && } + {multiColumn && }
- {!isSearchPage &&
+
@@ -128,9 +120,9 @@ class Compose extends React.PureComponent {
-
} +
- + {({ x }) => (
diff --git a/app/javascript/mastodon/features/ui/components/compose_panel.js b/app/javascript/mastodon/features/ui/components/compose_panel.js index 1d481eab52c..92d16b5b34e 100644 --- a/app/javascript/mastodon/features/ui/components/compose_panel.js +++ b/app/javascript/mastodon/features/ui/components/compose_panel.js @@ -6,7 +6,7 @@ import ComposeFormContainer from 'mastodon/features/compose/containers/compose_f import NavigationContainer from 'mastodon/features/compose/containers/navigation_container'; import LinkFooter from './link_footer'; import ServerBanner from 'mastodon/components/server_banner'; -import { changeComposing } from 'mastodon/actions/compose'; +import { changeComposing, mountCompose, unmountCompose } from 'mastodon/actions/compose'; export default @connect() class ComposePanel extends React.PureComponent { @@ -20,11 +20,23 @@ class ComposePanel extends React.PureComponent { }; onFocus = () => { - this.props.dispatch(changeComposing(true)); + const { dispatch } = this.props; + dispatch(changeComposing(true)); } onBlur = () => { - this.props.dispatch(changeComposing(false)); + const { dispatch } = this.props; + dispatch(changeComposing(false)); + } + + componentDidMount () { + const { dispatch } = this.props; + dispatch(mountCompose()); + } + + componentWillUnmount () { + const { dispatch } = this.props; + dispatch(unmountCompose()); } render() {