@@ -48,7 +48,7 @@ const ConnectionPath = ({
4848 const tgtWidth = useTableWidthStoredValue ( targetTableName ) ;
4949 const [ isHovered , setIsHovered ] = useState ( false ) ;
5050 const [ btnVisible , setBtnVisible ] = useState ( false ) ;
51- const [ btnPos , setBtnPos ] = useState ( { x : 0 , y : 0 } ) ;
51+ const [ btnPos , setBtnPos ] = useState < XYPosition > ( { x : 0 , y : 0 } ) ;
5252 const [ btnAngle , setBtnAngle ] = useState ( 0 ) ;
5353 const [ btnTarget , setBtnTarget ] = useState < string | null > ( null ) ;
5454 const [ btnHovering , setBtnHovering ] = useState ( false ) ;
@@ -201,6 +201,17 @@ const ConnectionPath = ({
201201 localY = py + DIAGRAM_PADDING ;
202202 btnStagePosRef . current = { x : px , y : py } ;
203203 }
204+ if ( btnStagePosRef . current == null ) {
205+ btnStagePosRef . current = { x : px , y : py } ;
206+ }
207+ const buttonPoint : XYPosition = { x : localX , y : localY } ;
208+ setBtnPos ( buttonPoint ) ;
209+ const edgeTarget = resolveTargetByEdgeDistance (
210+ buttonPoint ,
211+ srcCoords ,
212+ tgtCoords ,
213+ ) ;
214+ setBtnTarget ( edgeTarget ) ;
204215
205216 // Decide visibility: hide when too close to path endpoints (prevents overlap with tables and relation markers).
206217 // Use a robust stage-space distance check between the current button
@@ -213,15 +224,6 @@ const ConnectionPath = ({
213224 END_LINE_TOLERATE ,
214225 ) ;
215226
216- const buttonPoint : XYPosition = { x : localX , y : localY } ;
217- setBtnPos ( buttonPoint ) ;
218- const edgeTarget = resolveTargetByEdgeDistance (
219- buttonPoint ,
220- srcCoords ,
221- tgtCoords ,
222- ) ;
223- setBtnTarget ( edgeTarget ) ;
224-
225227 // Ensure arrow is above relation lines but below table nodes. We look for
226228 // the first child whose name starts with `table-` and set the arrow's
227229 // z-index to just before that index. If no table child is found, move the
0 commit comments