From fcb6de39f347c7eec78660fa168bb7722cd0eabd Mon Sep 17 00:00:00 2001 From: Ben Wheeler Date: Tue, 12 Nov 2019 15:22:40 -0500 Subject: [PATCH] more precise case for resetting project title to default --- src/lib/titled-hoc.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib/titled-hoc.jsx b/src/lib/titled-hoc.jsx index ab0cfd68b..53bd71efd 100644 --- a/src/lib/titled-hoc.jsx +++ b/src/lib/titled-hoc.jsx @@ -3,7 +3,10 @@ import React from 'react'; import {connect} from 'react-redux'; import {defineMessages, injectIntl, intlShape} from 'react-intl'; -import {getIsShowingWithoutId} from '../reducers/project-state'; +import { + getIsAnyCreatingNewState, + getIsShowingWithoutId +} from '../reducers/project-state'; import {setProjectTitle} from '../reducers/project-title'; const messages = defineMessages({ @@ -27,7 +30,7 @@ const TitledHOC = function (WrappedComponent) { if (this.props.projectTitle !== prevProps.projectTitle) { this.handleReceivedProjectTitle(this.props.projectTitle); } - if (this.props.isShowingWithoutId && !prevProps.isShowingWithoutId) { + if (this.props.isShowingWithoutId && prevProps.isAnyCreatingNewState) { const defaultProjectTitle = this.handleReceivedProjectTitle(); this.props.onUpdateProjectTitle(defaultProjectTitle); } @@ -50,6 +53,7 @@ const TitledHOC = function (WrappedComponent) { const { /* eslint-disable no-unused-vars */ intl, + isAnyCreatingNewState, isShowingWithoutId, onChangedProjectTitle, // for children, we replace onUpdateProjectTitle with our own @@ -71,6 +75,7 @@ const TitledHOC = function (WrappedComponent) { TitledComponent.propTypes = { intl: intlShape, + isAnyCreatingNewState: PropTypes.bool, isShowingWithoutId: PropTypes.bool, onChangedProjectTitle: PropTypes.func, onUpdateProjectTitle: PropTypes.func, @@ -85,6 +90,7 @@ const TitledHOC = function (WrappedComponent) { const mapStateToProps = state => { const loadingState = state.scratchGui.projectState.loadingState; return { + isAnyCreatingNewState: getIsAnyCreatingNewState(loadingState), isShowingWithoutId: getIsShowingWithoutId(loadingState), reduxProjectTitle: state.scratchGui.projectTitle };