Skip to content

Flows are invisible on creation, if created left or up #110

Closed

Description

@filipesmedeiros

Hey!

If a person creates a flow, but initially moves it up or left, the flow will be invisible and jittery. I haven't been able to fix this issue after trying for a few hours, but I do have some pointers for you, @bpowers :)

First, here is a video of the problem:

Screen.Recording.2025-08-26.at.11.41.46.mov

Second, here are the problematic lines I have found.

Inside this loop:

for (let j = 0; j < pts.size; j++) {
let x = defined(pts.get(j)).x;
let y = defined(pts.get(j)).y;
if (j === pts.size - 1) {
const dx = x - defined(pts.get(j - 1)).x;
const dy = y - defined(pts.get(j - 1)).y;
let θ = (atan2(dy, dx) * 180) / PI;
if (θ < 0) {
θ += 360;
}
if (θ >= 315 || θ < 45) {
x -= finalAdjust;
arrowθ = 0;
} else if (θ >= 45 && θ < 135) {
y -= finalAdjust;
arrowθ = 90;
} else if (θ >= 135 && θ < 225) {
x += finalAdjust;
arrowθ = 180;
} else {
y += finalAdjust;
arrowθ = 270;
}
}

The value of θ is always 0 or 90, which leads me to believe it is never 270 or 180 (left and up).

This seems to be because the points returned in

let pts = this.props.element.points;

are always greater than or equal to the original drag. In other words, if you start a flow at point (10, 10), even if you drag left, the second point will be (10, 10).

Most notably, this only happens on creation. After you have dragged it to "down or right" and the flow appears, dragging it back to "left or up" works as intended, as shown in the video.

I don't know why this is the case, but hopefully my contribution will be enough to fix the problem :)

Activity

  1. added
    frontend
    bug
    on Jun 8, 2026
  2. bpowers commented on Jul 3, 2026

    @bpowers
    Owner

    Verified fixed at HEAD (interactive-editing burndown pass, 2026-07-02).

    The degenerate-axis recovery in adjustFlows (src/diagram/drawing/Flow.tsx) now classifies the in-creation flow's axis by the larger-magnitude component of the source->target delta (Math.abs comparison), which handles the negative direction on both axes; regression tests cover LEFTWARD and UPWARD creation drags in src/diagram/tests/flow-attach.test.ts ('the sink follows a LEFTWARD/UPWARD cursor (not degenerate)') and src/diagram/tests/flow-routing.test.ts (UpdateCloudAndFlow degenerate flow creation, all four directions).

    Also browser-verified against the dev server: creating a flow and dragging left renders the live preview (line, valve, arrowhead) tracking the cursor leftward; same for upward. Both commit correctly. No invisible/jittery behavior remains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfrontend

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions