@@ -20,12 +20,12 @@ export class TopologyTooltipPopover implements TopologyTooltip {
20
20
private readonly injector : Injector ,
21
21
private readonly popoverService : PopoverService
22
22
) {
23
- this . popoverSubject = new BehaviorSubject ( this . buildPopover ( false ) ) ;
23
+ this . popoverSubject = new BehaviorSubject ( this . buildPopover ( null , false ) ) ;
24
24
this . hidden$ = this . popoverSubject . pipe ( switchMap ( popover => merge ( popover . hidden$ , popover . closed$ ) ) ) ;
25
25
}
26
26
27
27
public showWithNodeData ( node : TopologyNode , options : TopologyTooltipOptions = { } ) : void {
28
- this . rebuildPopoverIfNeeded ( options ) ;
28
+ this . rebuildPopoverIfNeeded ( node , options ) ;
29
29
this . dataSubject . next ( {
30
30
type : 'node' ,
31
31
node : node ,
@@ -35,7 +35,7 @@ export class TopologyTooltipPopover implements TopologyTooltip {
35
35
}
36
36
37
37
public showWithEdgeData ( edge : TopologyEdge , options : TopologyTooltipOptions = { } ) : void {
38
- this . rebuildPopoverIfNeeded ( options ) ;
38
+ this . rebuildPopoverIfNeeded ( edge , options ) ;
39
39
this . dataSubject . next ( {
40
40
type : 'edge' ,
41
41
edge : edge ,
@@ -54,17 +54,17 @@ export class TopologyTooltipPopover implements TopologyTooltip {
54
54
this . popoverSubject . complete ( ) ;
55
55
}
56
56
57
- private rebuildPopoverIfNeeded ( options : TopologyTooltipOptions ) : void {
57
+ private rebuildPopoverIfNeeded ( node : TopologyNode | TopologyEdge , options : TopologyTooltipOptions ) : void {
58
58
const modal = ! ! options . modal ;
59
59
if ( modal === this . popover . hasBackdrop ( ) ) {
60
60
return ;
61
61
}
62
62
63
63
this . popover . close ( ) ; // Close existing popover
64
- this . popoverSubject . next ( this . buildPopover ( modal ) ) ;
64
+ this . popoverSubject . next ( this . buildPopover ( node , modal ) ) ;
65
65
}
66
66
67
- private buildPopover ( modal : boolean ) : PopoverRef {
67
+ private buildPopover ( node : any , modal : boolean ) : PopoverRef {
68
68
const popover = this . popoverService . drawPopover ( {
69
69
componentOrTemplate : this . tooltipDefinition . class ,
70
70
position : {
@@ -81,11 +81,27 @@ export class TopologyTooltipPopover implements TopologyTooltip {
81
81
82
82
popover . updatePositionStrategy ( {
83
83
type : PopoverPositionType . FollowMouse ,
84
- boundingElement : this . container . nativeElement ,
84
+ boundingElement : this . getElementContainer ( node ?. data ?. name , modal ) ,
85
85
offsetX : 50 ,
86
86
offsetY : 30
87
87
} ) ;
88
88
89
89
return popover ;
90
90
}
91
+
92
+ private getElementContainer ( textContent : string = '' , modal : boolean ) : HTMLElement {
93
+ if ( ! modal ) {
94
+ return this . container . nativeElement ;
95
+ }
96
+
97
+ if ( textContent ) {
98
+ return (
99
+ Array . from ( this . container . nativeElement . querySelector ( '.topology-data' ) . children as HTMLCollection ) . find (
100
+ el => el . querySelector ( 'text' ) ?. textContent === textContent
101
+ ) ?? this . container . nativeElement
102
+ ) ;
103
+ } else {
104
+ return this . container . nativeElement . querySelector ( '.topology-data .emphasized' ) ;
105
+ }
106
+ }
91
107
}
0 commit comments