Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/components/shared/ReactFlow/FlowCanvas/Edges/SmoothEdge.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { EdgeProps } from "@xyflow/react";
import { getBezierPath, useEdges } from "@xyflow/react";
import { getBezierPath, useEdges, useNodes } from "@xyflow/react";

import { EdgeColor } from "./utils";

Expand All @@ -15,7 +15,15 @@ const SmoothEdge = ({
selected,
}: EdgeProps) => {
const edges = useEdges();
const hasAnySelectedEdge = edges.some((edge) => edge.selected);
const nodes = useNodes();

const selectedNodes = nodes.filter((node) => node.selected);
const isMultiSelect = selectedNodes.length > 1;

// Don't highlight edges during multi-select to avoid visual clutter
const effectiveSelected = selected && !isMultiSelect;
const hasAnySelectedEdge =
!isMultiSelect && edges.some((edge) => edge.selected);

const [edgePath] = getBezierPath({
sourceX,
Expand All @@ -27,13 +35,13 @@ const SmoothEdge = ({
});

const getEdgeColor = () => {
if (selected) return EdgeColor.Selected;
if (effectiveSelected) return EdgeColor.Selected;
if (hasAnySelectedEdge) return EdgeColor.Muted;
return EdgeColor.Neutral;
};

const edgeColor = getEdgeColor();
const markerIdSuffix = selected
const markerIdSuffix = effectiveSelected
? "selected"
: hasAnySelectedEdge
? "muted"
Expand Down
11 changes: 10 additions & 1 deletion src/hooks/useEdgeSelectionHighlight.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import { useEdges } from "@xyflow/react";
import { useEdges, useNodes } from "@xyflow/react";

export function useEdgeSelectionHighlight(nodeId: string) {
const edges = useEdges();
const nodes = useNodes();

const selectedNodes = nodes.filter((node) => node.selected);

// Disable edge highlighting when multiple nodes are selected (multi-select scenario)
// to avoid highlighting nodes outside the selection
if (selectedNodes.length > 1) {
return false;
}

const selectedEdges = edges.filter((edge) => edge.selected);
const isConnectedToSelectedEdge =
Expand Down