Skip to content

Commit f51f8be

Browse files
Merge pull request #171 from Saifullah-dev/169-fix-exit-rename-with-esc-key
fix(Rename Action): Rename action can now be canceled with ESC key
2 parents 014d85c + 1d74f9d commit f51f8be

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

frontend/src/FileManager/Actions/CreateFolder/CreateFolder.action.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ const CreateFolderAction = ({ filesViewRef, file, onCreateFolder, triggerAction
3838
return;
3939
}
4040

41-
if (e.key === 'Escape') {
41+
if (e.key === "Escape") {
4242
e.preventDefault();
4343
triggerAction.close();
4444
setCurrentPathFiles((prev) => prev.filter((f) => f.key !== file.key));
45+
return;
4546
}
4647

4748
const invalidCharsRegex = /[\\/:*?"<>|]/;

frontend/src/FileManager/Actions/Rename/Rename.action.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@ const RenameAction = ({ filesViewRef, file, onRename, triggerAction }) => {
3838
return;
3939
}
4040

41+
if (e.key === "Escape") {
42+
e.preventDefault();
43+
setCurrentPathFiles((prev) =>
44+
prev.map((f) => {
45+
if (f.key === file.key) {
46+
f.isEditing = false;
47+
}
48+
return f;
49+
})
50+
);
51+
triggerAction.close();
52+
return;
53+
}
54+
4155
const invalidCharsRegex = /[\\/:*?"<>|]/;
4256
if (invalidCharsRegex.test(e.key)) {
4357
e.preventDefault();

0 commit comments

Comments
 (0)