@@ -95,6 +95,18 @@ define(function (require, exports, module) {
95
95
* and invoking the correct action based on that input.
96
96
*/
97
97
var renameBehavior = {
98
+ /**
99
+ * Stop clicks from propagating so that clicking on the rename input doesn't
100
+ * cause directories to collapse.
101
+ */
102
+ handleClick : function ( e ) {
103
+ e . stopPropagation ( ) ;
104
+ if ( e . button !== LEFT_MOUSE_BUTTON ) {
105
+ return false ;
106
+ }
107
+ return true ;
108
+ } ,
109
+
98
110
/**
99
111
* If the user presses enter or escape, we either successfully complete or cancel, respectively,
100
112
* the rename or create operation that is underway.
@@ -169,12 +181,13 @@ define(function (require, exports, module) {
169
181
var width = _measureText ( this . props . name ) ;
170
182
171
183
return DOM . input ( {
172
- className : "jstree-rename-input " + this . props . fileClasses ,
184
+ className : "jstree-rename-input" ,
173
185
type : "text" ,
174
186
defaultValue : this . props . name ,
175
187
autoFocus : true ,
176
188
onKeyDown : this . handleKeyDown ,
177
189
onKeyUp : this . handleKeyUp ,
190
+ onClick : this . handleClick ,
178
191
onBlur : this . handleBlur ,
179
192
style : {
180
193
width : width
@@ -432,8 +445,7 @@ define(function (require, exports, module) {
432
445
actions : this . props . actions ,
433
446
entry : this . props . entry ,
434
447
name : this . props . name ,
435
- parentPath : this . props . parentPath ,
436
- fileClasses : fileClasses
448
+ parentPath : this . props . parentPath
437
449
} ) ;
438
450
} else {
439
451
// Need to flatten the argument list because getIcons returns an array
@@ -530,10 +542,11 @@ define(function (require, exports, module) {
530
542
onKeyDown : this . handleKeyDown ,
531
543
onKeyUp : this . handleKeyUp ,
532
544
onBlur : this . handleBlur ,
533
- ref : "name" ,
534
545
style : {
535
546
width : width
536
- }
547
+ } ,
548
+ onClick : this . handleClick ,
549
+ ref : "name"
537
550
} ) ;
538
551
}
539
552
} ) ;
@@ -646,22 +659,26 @@ define(function (require, exports, module) {
646
659
directoryClasses += " context-node" ;
647
660
}
648
661
649
- var nameDisplay ;
662
+ var nameDisplay , renameInput ;
650
663
if ( entry . get ( "rename" ) ) {
651
- nameDisplay = directoryRenameInput ( {
664
+ renameInput = directoryRenameInput ( {
652
665
actions : this . props . actions ,
653
666
entry : this . props . entry ,
654
667
name : this . props . name ,
655
668
parentPath : this . props . parentPath
656
669
} ) ;
657
- } else {
658
- // Need to flatten the arguments because getIcons returns an array
659
- var aArgs = _ . flatten ( [ {
660
- href : "#" ,
661
- className : directoryClasses
662
- } , this . getIcons ( ) , this . props . name ] , true ) ;
663
- nameDisplay = DOM . a . apply ( DOM . a , aArgs ) ;
664
670
}
671
+
672
+ // Need to flatten the arguments because getIcons returns an array
673
+ var aArgs = _ . flatten ( [ {
674
+ href : "#" ,
675
+ className : directoryClasses
676
+ } , this . getIcons ( ) ] , true ) ;
677
+ if ( ! entry . get ( "rename" ) ) {
678
+ aArgs . push ( this . props . name ) ;
679
+ }
680
+
681
+ nameDisplay = DOM . a . apply ( DOM . a , aArgs ) ;
665
682
666
683
return DOM . li ( {
667
684
className : this . getClasses ( "jstree-" + nodeClass ) ,
@@ -671,6 +688,7 @@ define(function (require, exports, module) {
671
688
DOM . ins ( {
672
689
className : "jstree-icon"
673
690
} , " " ) ,
691
+ renameInput ,
674
692
nameDisplay ,
675
693
childNodes ) ;
676
694
}
0 commit comments