Skip to content

Commit

Permalink
fix: fix validate
Browse files Browse the repository at this point in the history
fix validate
  • Loading branch information
zhangtengjin committed Dec 3, 2020
1 parent c017b7c commit 6b7887e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/components/tree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
console.log('treeData', treeData);
onDropTree && onDropTree(treeData)
};
const onEnter = (e, file, index) => {
if (e.keyCode === 13) {
updateFile && updateFile(file, e.target.value, index)
}
}
const renderTreeNodes = (data) =>
data?.map((item, index) => {
const {
Expand All @@ -182,6 +187,8 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
data-id={generateTreeId(id)}
data={item}
title={modify ? <input
type='text'
onKeyDown={(e: any) => { onEnter(e, item, index) }}
autoComplete='off'
onBlur={(e) => {
updateFile && updateFile(item, e.target.value, index)
Expand Down
6 changes: 4 additions & 2 deletions src/services/workbench/explorerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,10 @@ export class ExplorerService
const update = (tree) => {
const rootNode = tree[0];
if (rootNode.id === fileData.id) {
rootNode.name = newName;
rootNode.modify = false;
if (newName) {
rootNode.name = newName;
rootNode.modify = false;
}
return tree
}
const loopById = (file, id) => {
Expand Down

0 comments on commit 6b7887e

Please sign in to comment.