Skip to content

Commit 177c621

Browse files
samdentyCompuIves
authored andcommitted
[Fix] Renaming directories (codesandbox#867)
* Edit -> Rename * Only rename files if the title changed
1 parent d24cd32 commit 177c621

File tree

2 files changed

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

2 files changed

+7
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function EditIcons({
3939
{(hovering || (window.__isTouch && active) || forceShow) && (
4040
<Container>
4141
{onEdit && (
42-
<Tooltip title="Edit">
42+
<Tooltip title="Rename">
4343
<Icon onClick={handleClick(onEdit)}>
4444
<EditIcon />
4545
</Icon>

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,13 @@ class Entry extends React.PureComponent {
4141
this.setState({ error: isInvalidTitle });
4242
};
4343

44-
handleRename = (title, force) => {
45-
const { shortid } = this.props;
46-
const canRename = !this.handleValidateTitle(title);
44+
handleRename = (newTitle, force) => {
45+
const { shortid, title } = this.props
46+
if (newTitle === title) return
47+
48+
const canRename = !this.handleValidateTitle(newTitle);
4749
if (canRename && this.props.rename) {
48-
this.props.rename(shortid, title);
50+
this.props.rename(shortid, newTitle);
4951
this.resetState();
5052
} else if (force) this.resetState();
5153
};

0 commit comments

Comments
 (0)