Fix click while renaming project item and warning when name is not changed

This commit is contained in:
Florian Rival
2019-03-07 23:13:37 +00:00
parent c31de12048
commit 96674f36b4
2 changed files with 17 additions and 5 deletions

View File

@@ -561,7 +561,7 @@ class MainFrame extends React.Component<Props, State> {
const { i18n } = this.props;
if (!currentProject) return;
if (!currentProject.hasLayoutNamed(oldName)) return;
if (!currentProject.hasLayoutNamed(oldName) || newName === oldName) return;
if (currentProject.hasLayoutNamed(newName)) {
showWarningBox(i18n._(t`Another scene with this name already exists.`));
@@ -585,7 +585,8 @@ class MainFrame extends React.Component<Props, State> {
const { i18n } = this.props;
if (!currentProject) return;
if (!currentProject.hasExternalLayoutNamed(oldName)) return;
if (!currentProject.hasExternalLayoutNamed(oldName) || newName === oldName)
return;
if (currentProject.hasExternalLayoutNamed(newName)) {
showWarningBox(
@@ -614,7 +615,8 @@ class MainFrame extends React.Component<Props, State> {
const { i18n } = this.props;
if (!currentProject) return;
if (!currentProject.hasExternalEventsNamed(oldName)) return;
if (!currentProject.hasExternalEventsNamed(oldName) || newName === oldName)
return;
if (currentProject.hasExternalEventsNamed(newName)) {
showWarningBox(
@@ -644,7 +646,11 @@ class MainFrame extends React.Component<Props, State> {
const { eventsFunctionWriter } = this.props;
if (!currentProject) return;
if (!currentProject.hasEventsFunctionsExtensionNamed(oldName)) return;
if (
!currentProject.hasEventsFunctionsExtensionNamed(oldName) ||
newName === oldName
)
return;
if (currentProject.hasEventsFunctionsExtensionNamed(newName)) {
showWarningBox(

View File

@@ -218,7 +218,13 @@ class Item extends React.Component<ItemProps, {||}> {
onContextMenu={this._onContextMenu}
primaryText={label}
rightIconButton={rightIconButton}
onClick={this.props.onEdit}
onClick={() => {
// It's essential to discard clicks when editing the name,
// to avoid weird opening of an editor (accompanied with a
// closing of the project manager) when clicking on the text
// field.
if (!this.props.editingName) this.props.onEdit();
}}
/>
)}
</ThemeConsumer>