@@ -1615,7 +1615,8 @@ class HierarchyPainter extends BasePainter {
16151615 }
16161616
16171617 // special feature - all items with '_expand' function are not drawn by click
1618- if ( ( place === 'item' ) && ( '_expand' in hitem ) && ! evnt . ctrlKey && ! evnt . shiftKey ) place = kPM ;
1618+ if ( ( place === 'item' ) && ( '_expand' in hitem ) && ! hitem . _expand_miss && ! evnt . ctrlKey && ! evnt . shiftKey )
1619+ place = kPM ;
16191620
16201621 // special case - one should expand item
16211622 if ( ( ( place === kPM ) && ! ( '_childs' in hitem ) && hitem . _more ) ||
@@ -2615,7 +2616,24 @@ class HierarchyPainter extends BasePainter {
26152616 if ( ! hitem && d3cont )
26162617 return ;
26172618
2619+ function doneExpandItem ( _item ) {
2620+ if ( _item . _childs === undefined )
2621+ _item . _expand_miss = true ;
2622+ else {
2623+ _item . _isopen = true ;
2624+ if ( _item . _parent && ! _item . _parent . _isopen ) {
2625+ _item . _parent . _isopen = true ; // also show parent
2626+ if ( ! silent )
2627+ hpainter . updateTreeNode ( _item . _parent ) ;
2628+ } else if ( ! silent )
2629+ hpainter . updateTreeNode ( _item , d3cont ) ;
2630+ }
2631+ return _item ;
2632+ }
2633+
26182634 async function doExpandItem ( _item , _obj ) {
2635+ delete _item . _expand_miss ;
2636+
26192637 if ( isStr ( _item . _expand ) )
26202638 _item . _expand = findFunction ( _item . _expand ) ;
26212639
@@ -2646,28 +2664,15 @@ class HierarchyPainter extends BasePainter {
26462664
26472665 // try to use expand function
26482666 if ( _obj && isFunc ( _item . _expand ) ) {
2649- if ( _item . _expand ( _item , _obj ) ) {
2650- _item . _isopen = true ;
2651- if ( _item . _parent && ! _item . _parent . _isopen ) {
2652- _item . _parent . _isopen = true ; // also show parent
2653- if ( ! silent )
2654- hpainter . updateTreeNode ( _item . _parent ) ;
2655- } else if ( ! silent )
2656- hpainter . updateTreeNode ( _item , d3cont ) ;
2657- return _item ;
2658- }
2667+ if ( _item . _expand ( _item , _obj ) )
2668+ return doneExpandItem ( _item ) ;
26592669 }
26602670
2661- if ( _obj && objectHierarchy ( _item , _obj ) ) {
2662- _item . _isopen = true ;
2663- if ( _item . _parent && ! _item . _parent . _isopen ) {
2664- _item . _parent . _isopen = true ; // also show parent
2665- if ( ! silent ) hpainter . updateTreeNode ( _item . _parent ) ;
2666- } else if ( ! silent )
2667- hpainter . updateTreeNode ( _item , d3cont ) ;
2668- return _item ;
2669- }
2671+ if ( _obj && objectHierarchy ( _item , _obj ) )
2672+ return doneExpandItem ( _item ) ;
26702673
2674+ // mark as expand miss - behaves as normal object
2675+ _item . _expand_miss = true ;
26712676 return - 1 ;
26722677 }
26732678
0 commit comments