@@ -204,6 +204,7 @@ $.ui.fancytree.registerExtension({
204204 autoExpandMS : 1000 , // Expand nodes after n milliseconds of hovering.
205205 preventVoidMoves : true , // Prevent dropping nodes 'before self', etc.
206206 preventRecursiveMoves : true , // Prevent dropping nodes on own descendants
207+ focusOnClick : false , // Focus, although draggable cancels mousedown event (#270)
207208 dragEnter : null , // Callback(targetNode, data)
208209 dragOver : null , // Callback(targetNode, data)
209210 dragDrop : null , // Callback(targetNode, data)
@@ -216,6 +217,20 @@ $.ui.fancytree.registerExtension({
216217 treeInit : function ( ctx ) {
217218 var tree = ctx . tree ;
218219 this . _super ( ctx ) ;
220+ // issue #270: draggable eats mousedown events
221+ if ( tree . options . dnd . dragStart ) {
222+ tree . $container . on ( "mousedown" , function ( event ) {
223+ if ( ! tree . hasFocus ( ) && ctx . options . dnd . focusOnClick ) {
224+ var node = $ . ui . fancytree . getNode ( event ) ;
225+ node . debug ( "Re-enable focus that was prevented by jQuery UI draggable." ) ;
226+ // node.setFocus();
227+ // $(node.span).closest(":tabbable").focus();
228+ // $(event.target).trigger("focus");
229+ // $(event.target).closest(":tabbable").trigger("focus");
230+ $ ( event . target ) . closest ( ":tabbable" ) . focus ( ) ;
231+ }
232+ } ) ;
233+ }
219234 _initDragAndDrop ( tree ) ;
220235 } ,
221236 /* Override key handler in order to cancel dnd on escape.*/
@@ -226,6 +241,12 @@ $.ui.fancytree.registerExtension({
226241 }
227242 return this . _super ( ctx ) ;
228243 } ,
244+ nodeClick : function ( ctx ) {
245+ // if( ctx.options.dnd.dragStart ){
246+ // ctx.tree.$container.focus();
247+ // }
248+ return this . _super ( ctx ) ;
249+ } ,
229250 /* Display drop marker according to hitMode ('after', 'before', 'over', 'out', 'start', 'stop'). */
230251 _setDndStatus : function ( sourceNode , targetNode , helper , hitMode , accept ) {
231252 var posOpts ,
0 commit comments