Skip to content

Commit 6b7887e

Browse files
committed
fix: fix validate
fix validate
1 parent c017b7c commit 6b7887e

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/components/tree/index.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,11 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
172172
console.log('treeData', treeData);
173173
onDropTree && onDropTree(treeData)
174174
};
175+
const onEnter = (e, file, index) => {
176+
if (e.keyCode === 13) {
177+
updateFile && updateFile(file, e.target.value, index)
178+
}
179+
}
175180
const renderTreeNodes = (data) =>
176181
data?.map((item, index) => {
177182
const {
@@ -182,6 +187,8 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
182187
data-id={generateTreeId(id)}
183188
data={item}
184189
title={modify ? <input
190+
type='text'
191+
onKeyDown={(e: any) => { onEnter(e, item, index) }}
185192
autoComplete='off'
186193
onBlur={(e) => {
187194
updateFile && updateFile(item, e.target.value, index)

src/services/workbench/explorerService.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,10 @@ export class ExplorerService
9292
const update = (tree) => {
9393
const rootNode = tree[0];
9494
if (rootNode.id === fileData.id) {
95-
rootNode.name = newName;
96-
rootNode.modify = false;
95+
if (newName) {
96+
rootNode.name = newName;
97+
rootNode.modify = false;
98+
}
9799
return tree
98100
}
99101
const loopById = (file, id) => {

0 commit comments

Comments
 (0)