Skip to content

feat: Highlight edge path on selection#196

Open
handreyrc wants to merge 5 commits into
serverlessworkflow:mainfrom
handreyrc:highlight-edge-path
Open

feat: Highlight edge path on selection#196
handreyrc wants to merge 5 commits into
serverlessworkflow:mainfrom
handreyrc:highlight-edge-path

Conversation

@handreyrc

Copy link
Copy Markdown
Contributor

Closes: #186

Summary

When paths are merged by the auto-layout, edges may overlap each other making it hard to follow. By selecting an edge it should be possible to clear visualize the whole path of that edge.

Changes

  • Brought selected edge to the top by setting a high z-index when an edge is selected and then restoring it when it is deselected.
  • Preserved edge stroke color on selection.
  • Added shade to the selected edge make its path easy to follow.
  • Added unit tests.
image image

Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copilot AI review requested due to automatic review settings June 23, 2026 20:18
@netlify

netlify Bot commented Jun 23, 2026

Copy link
Copy Markdown

Deploy Preview for swf-editor ready!

Name Link
🔨 Latest commit 521c552
🔍 Latest deploy log https://app.netlify.com/projects/swf-editor/deploys/6a3bf080f5facd00089936bf
😎 Deploy Preview https://deploy-preview-196--swf-editor.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds improved edge-selection visibility in the Serverless Workflow diagram editor to make overlapping/merged edge paths easier to follow by elevating selected edges visually and in render order.

Changes:

  • Add a selected-aware edge path class so selected edges can be styled distinctly.
  • Update edge change handling to set a high zIndex for selected edges.
  • Add/extend unit tests and introduce a changeset for the feature release.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/serverless-workflow-diagram-editor/src/react-flow/edges/Edges.tsx Appends a selected class to edge paths when an edge is selected.
packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.tsx Updates onEdgesChange to assign zIndex based on selection state.
packages/serverless-workflow-diagram-editor/src/react-flow/diagram/Diagram.css Adds selected-edge styling to preserve stroke colors and apply a drop-shadow highlight.
packages/serverless-workflow-diagram-editor/tests/react-flow/edges/Edges.test.tsx Adds parameterized tests verifying selected vs non-selected edge class behavior.
packages/serverless-workflow-diagram-editor/tests/react-flow/diagram/Diagram.test.tsx Adds tests around onEdgesChange / zIndex behavior (with a noted test-quality issue).
.changeset/edge-path-highlight.md Declares a minor version bump for the diagram editor package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: handreyrc <handrey.cunha@gmail.com>

/* Override React Flow's default selected edge styling to preserve original colors */
.dec-root .react-flow__edge.selected .edge-line {
stroke: #aea6a6 !important;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add this color to a css var to make it easier to manage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

}

.dec-root .react-flow__edge.selected .edge-line.condition {
stroke: rgb(59 130 246) !important;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also extract this color to a var

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

Comment on lines +176 to +178
const edgeClassName = selected
? `${className ?? "edge-line"} selected`
: (className ?? "edge-line");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const edgeClassName = selected
? `${className ?? "edge-line"} selected`
: (className ?? "edge-line");
const edgeClassName = `${className ?? "edge-line"}${selected ? " selected" : ""}`;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

expect(typeof onEdgesChange).toBe("function");
});

it("should apply zIndex correctly when edges are updated", async () => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test shows this warning, can we fix it?

stderr | tests/react-flow/diagram/Diagram.test.tsx > Diagram Component > onEdgesChange with zIndex updates > should apply zIndex correctly when edges are updated
An update to DiagramEditorContextProvider inside a test was not wrapped in act(...).

When testing, code that causes React state updates should be wrapped into act(...):

act(() => {
  /* fire events that update state */
});
/* assert on the output */

This ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed!

@lornakelly

lornakelly commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@handreyrc Thanks for the PR, wondering if when you select an edge with a label, the label stays on top of the line if that label is for that edge

For example, here it makes sense that the edge is over sessionStarted as its the statusError edge that is selected. But would be good to have the statusError label appear on top of the edge
Screenshot 2026-06-24 at 10 27 58

Signed-off-by: handreyrc <handrey.cunha@gmail.com>
Copilot AI review requested due to automatic review settings June 24, 2026 14:39
@handreyrc

Copy link
Copy Markdown
Contributor Author

@handreyrc Thanks for the PR, wondering if when you select an edge with a label, the label stays on top of the line if that label is for that edge

For example, here it makes sense that the edge is over sessionStarted as its the statusError edge that is selected. But would be good to have the statusError label appear on top of the edge Screenshot 2026-06-24 at 10 27 58

@lornakelly,

There is a general z-index issue around labels. They are also being drawn behind parent nodes.
I'll open an issue for that and fix it in a separate PR.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread packages/serverless-workflow-diagram-editor/tests/react-flow/edges/Edges.test.tsx Outdated
Signed-off-by: handreyrc <handrey.cunha@gmail.com>
@handreyrc handreyrc requested a review from fantonangeli June 24, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Highlight edge path on selection

4 participants