Skip to content

Commit 2c8db68

Browse files
emersonlaurentinoCompuIves
authored andcommitted
fix(EntryTitleInput): in event onblur if force is true it calls reset… (codesandbox#913)
* fix(EntryTitleInput): in event onblur if force is true it calls resetState * chore(EntryTitleInput): remove return on call functions * fix(EntryTitleInput): prioritize function rename and then after resetState
1 parent 8504aef commit 2c8db68

File tree

2 files changed

+9
-5
lines changed
  • packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry

2 files changed

+9
-5
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/EntryTitleInput/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export default class EntryTitleInput extends React.PureComponent {
4040
<InputContainer>
4141
<input
4242
onChange={this.handleChange}
43-
onBlur={() => onCommit(this.state.currentValue, true)}
43+
onBlur={() => onCommit(currentValue, true)}
4444
onKeyUp={this.handleKeyUp}
4545
ref={select}
4646
value={currentValue}

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ class Entry extends React.PureComponent {
4242
};
4343

4444
handleRename = (newTitle, force) => {
45-
const { shortid, title } = this.props;
45+
const { shortid, title, rename } = this.props;
46+
4647
if (newTitle === title) return;
4748

4849
const canRename = !this.handleValidateTitle(newTitle);
49-
if (canRename && this.props.rename) {
50-
this.props.rename(shortid, newTitle);
50+
51+
if (newTitle !== title && canRename && rename) {
52+
rename(shortid, newTitle);
5153
this.resetState();
52-
} else if (force) this.resetState();
54+
} else if (force) {
55+
this.resetState();
56+
}
5357
};
5458

5559
delete = () => {

0 commit comments

Comments
 (0)