Skip to content

Commit fcb6de3

Browse files
committed
more precise case for resetting project title to default
1 parent 3c6e972 commit fcb6de3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/lib/titled-hoc.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ import React from 'react';
33
import {connect} from 'react-redux';
44
import {defineMessages, injectIntl, intlShape} from 'react-intl';
55

6-
import {getIsShowingWithoutId} from '../reducers/project-state';
6+
import {
7+
getIsAnyCreatingNewState,
8+
getIsShowingWithoutId
9+
} from '../reducers/project-state';
710
import {setProjectTitle} from '../reducers/project-title';
811

912
const messages = defineMessages({
@@ -27,7 +30,7 @@ const TitledHOC = function (WrappedComponent) {
2730
if (this.props.projectTitle !== prevProps.projectTitle) {
2831
this.handleReceivedProjectTitle(this.props.projectTitle);
2932
}
30-
if (this.props.isShowingWithoutId && !prevProps.isShowingWithoutId) {
33+
if (this.props.isShowingWithoutId && prevProps.isAnyCreatingNewState) {
3134
const defaultProjectTitle = this.handleReceivedProjectTitle();
3235
this.props.onUpdateProjectTitle(defaultProjectTitle);
3336
}
@@ -50,6 +53,7 @@ const TitledHOC = function (WrappedComponent) {
5053
const {
5154
/* eslint-disable no-unused-vars */
5255
intl,
56+
isAnyCreatingNewState,
5357
isShowingWithoutId,
5458
onChangedProjectTitle,
5559
// for children, we replace onUpdateProjectTitle with our own
@@ -71,6 +75,7 @@ const TitledHOC = function (WrappedComponent) {
7175

7276
TitledComponent.propTypes = {
7377
intl: intlShape,
78+
isAnyCreatingNewState: PropTypes.bool,
7479
isShowingWithoutId: PropTypes.bool,
7580
onChangedProjectTitle: PropTypes.func,
7681
onUpdateProjectTitle: PropTypes.func,
@@ -85,6 +90,7 @@ const TitledHOC = function (WrappedComponent) {
8590
const mapStateToProps = state => {
8691
const loadingState = state.scratchGui.projectState.loadingState;
8792
return {
93+
isAnyCreatingNewState: getIsAnyCreatingNewState(loadingState),
8894
isShowingWithoutId: getIsShowingWithoutId(loadingState),
8995
reduxProjectTitle: state.scratchGui.projectTitle
9096
};

0 commit comments

Comments
 (0)