@@ -470,52 +470,60 @@ class ObjectTreeReact extends React.Component<IProps, IStates> {
470470 } }
471471 onClick = { ( ) => this . setState ( { editingNode : opts . node . id } ) }
472472 >
473- { this . state . editingNode === opts . node . id ? (
474- < input
475- type = "text"
476- value = { this . state . editingNodeValue || opts . node . label }
477- autoFocus
478- onBlur = { ( ) => this . setState ( { editingNode : null } ) }
479- onChange = { ( e ) =>
480- this . setState ( { editingNodeValue : e . target . value } )
481- }
482- onKeyDown = { ( e ) => {
483- if ( e . key === 'Enter' ) {
484- console . log ( 'Updated name:' , this . state . editingNodeValue ) ;
485- const updatedName = this . state . editingNodeValue ;
486- const objectName = opts . node . id ;
487-
488- if ( this . props . cpModel . mainViewModel ) {
489- const obj = this . props . cpModel . jcadModel ?. sharedModel . getObjectByName ( objectName as string ) ;
490- if ( obj ) {
491- this . props . cpModel . sharedModel ?. updateObjectByName ( objectName as string , {
492- data : {
493- key : 'name' ,
494- value : updatedName
495- }
473+ { this . state . editingNode === opts . node . id ? (
474+ < input
475+ type = "text"
476+ value = { this . state . editingNodeValue || opts . node . label }
477+ autoFocus
478+ onBlur = { ( ) => this . setState ( { editingNode : null } ) }
479+ onChange = { e =>
480+ this . setState ( { editingNodeValue : e . target . value } )
481+ }
482+ onKeyDown = { e => {
483+ if ( e . key === 'Enter' ) {
484+ console . log (
485+ 'Updated name:' ,
486+ this . state . editingNodeValue
487+ ) ;
488+ const updatedName = this . state . editingNodeValue ;
489+ const objectName = opts . node . id ;
490+
491+ if ( this . props . cpModel . mainViewModel ) {
492+ const obj =
493+ this . props . cpModel . jcadModel ?. sharedModel . getObjectByName (
494+ objectName as string
495+ ) ;
496+ if ( obj ) {
497+ this . props . cpModel . sharedModel ?. updateObjectByName (
498+ objectName as string ,
499+ {
500+ data : {
501+ key : 'name' ,
502+ value : updatedName
503+ }
504+ }
505+ ) ;
496506 }
497- ) ;
498507 }
508+ this . setState ( {
509+ editingNode : null ,
510+ editingNodeValue : null
511+ } ) ;
499512 }
500- this . setState ( {
501- editingNode : null ,
502- editingNodeValue : null
503- } ) ;
504- }
505- } }
506- style = { {
507- width : '100%' ,
508- background : 'transparent' ,
509- border : 'none' ,
510- outline : 'none' ,
511- fontSize : 'inherit' ,
512- color : 'inherit'
513- } }
514- />
515- ) : (
516- opts . node . label
517- ) }
518- </ span >
513+ } }
514+ style = { {
515+ width : '100%' ,
516+ background : 'transparent' ,
517+ border : 'none' ,
518+ outline : 'none' ,
519+ fontSize : 'inherit' ,
520+ color : 'inherit'
521+ } }
522+ />
523+ ) : (
524+ opts . node . label
525+ ) }
526+ </ span >
519527 { opts . type === 'leaf' ? (
520528 < div style = { { display : 'flex' } } >
521529 < ToolbarButtonComponent
0 commit comments