File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -172,6 +172,11 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
172
172
console . log ( 'treeData' , treeData ) ;
173
173
onDropTree && onDropTree ( treeData )
174
174
} ;
175
+ const onEnter = ( e , file , index ) => {
176
+ if ( e . keyCode === 13 ) {
177
+ updateFile && updateFile ( file , e . target . value , index )
178
+ }
179
+ }
175
180
const renderTreeNodes = ( data ) =>
176
181
data ?. map ( ( item , index ) => {
177
182
const {
@@ -182,6 +187,8 @@ const TreeView: React.FunctionComponent<ITreeProps> = (props: ITreeProps) => {
182
187
data-id = { generateTreeId ( id ) }
183
188
data = { item }
184
189
title = { modify ? < input
190
+ type = 'text'
191
+ onKeyDown = { ( e : any ) => { onEnter ( e , item , index ) } }
185
192
autoComplete = 'off'
186
193
onBlur = { ( e ) => {
187
194
updateFile && updateFile ( item , e . target . value , index )
Original file line number Diff line number Diff line change @@ -92,8 +92,10 @@ export class ExplorerService
92
92
const update = ( tree ) => {
93
93
const rootNode = tree [ 0 ] ;
94
94
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
+ }
97
99
return tree
98
100
}
99
101
const loopById = ( file , id ) => {
You can’t perform that action at this time.
0 commit comments