@@ -16,6 +16,8 @@ public class PortRenderer : ComponentBase, IDisposable
16
16
{
17
17
private bool _shouldRender = true ;
18
18
private ElementReference _element ;
19
+ private bool _updatingDimensions ;
20
+ private bool _shouldRefreshPort ;
19
21
20
22
[ CascadingParameter ]
21
23
public Diagram Diagram { get ; set ; }
@@ -105,6 +107,7 @@ private PortModel FindPortOn(double clientX, double clientY)
105
107
106
108
private async Task UpdateDimensions ( )
107
109
{
110
+ _updatingDimensions = true ;
108
111
var zoom = Diagram . Zoom ;
109
112
var pan = Diagram . Pan ;
110
113
var rect = await JSRuntime . GetBoundingClientRect ( _element ) ;
@@ -114,14 +117,28 @@ private async Task UpdateDimensions()
114
117
( rect . Top - Diagram . Container . Top - pan . Y ) / zoom ) ;
115
118
116
119
Port . Initialized = true ;
120
+ _updatingDimensions = false ;
117
121
118
- // We don't really need to refresh the port again,
119
- // let's just refresh the links so that they use the new port's position
120
- Port . RefreshLinks ( ) ;
122
+ if ( _shouldRefreshPort )
123
+ {
124
+ _shouldRefreshPort = false ;
125
+ Port . RefreshAll ( ) ;
126
+ }
127
+ else
128
+ {
129
+ Port . RefreshLinks ( ) ;
130
+ }
121
131
}
122
132
123
133
private async void OnPortChanged ( )
124
134
{
135
+ // If an update is ongoing and the port is refreshed again,
136
+ // it's highly likely the port needs to be refreshed (e.g. link added)
137
+ if ( _updatingDimensions )
138
+ {
139
+ _shouldRefreshPort = true ;
140
+ }
141
+
125
142
if ( Port . Initialized )
126
143
{
127
144
_shouldRender = true ;
0 commit comments