fix(canvas): restore visible handle glow during drag
This commit is contained in:
@@ -27,6 +27,16 @@ const reactFlowStateRef: {
|
||||
},
|
||||
};
|
||||
|
||||
const connectionStateRef: {
|
||||
current: {
|
||||
fromHandle?: { type?: "source" | "target" };
|
||||
};
|
||||
} = {
|
||||
current: {
|
||||
fromHandle: { type: "source" },
|
||||
},
|
||||
};
|
||||
|
||||
vi.mock("@xyflow/react", async () => {
|
||||
const actual = await vi.importActual<typeof import("@xyflow/react")>("@xyflow/react");
|
||||
|
||||
@@ -36,6 +46,7 @@ vi.mock("@xyflow/react", async () => {
|
||||
getNodes: () => reactFlowStateRef.current.nodes,
|
||||
getEdges: () => reactFlowStateRef.current.edges,
|
||||
}),
|
||||
useConnection: () => connectionStateRef.current,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -93,6 +104,7 @@ describe("CustomConnectionLine", () => {
|
||||
function renderLine(args?: {
|
||||
withMagnetHandle?: boolean;
|
||||
connectionStatus?: ConnectionLineComponentProps["connectionStatus"];
|
||||
omitFromHandleType?: boolean;
|
||||
}) {
|
||||
document
|
||||
.querySelectorAll("[data-testid='custom-line-magnet-handle']")
|
||||
@@ -106,6 +118,10 @@ describe("CustomConnectionLine", () => {
|
||||
edges: [],
|
||||
};
|
||||
|
||||
connectionStateRef.current = {
|
||||
fromHandle: { type: "source" },
|
||||
};
|
||||
|
||||
if (args?.withMagnetHandle && container) {
|
||||
const handleEl = document.createElement("div");
|
||||
handleEl.setAttribute("data-testid", "custom-line-magnet-handle");
|
||||
@@ -128,11 +144,19 @@ describe("CustomConnectionLine", () => {
|
||||
}
|
||||
|
||||
act(() => {
|
||||
const lineProps = {
|
||||
...baseProps,
|
||||
fromHandle: {
|
||||
...baseProps.fromHandle,
|
||||
...(args?.omitFromHandleType ? { type: undefined } : null),
|
||||
},
|
||||
} as ConnectionLineComponentProps;
|
||||
|
||||
root?.render(
|
||||
<CanvasConnectionMagnetismProvider>
|
||||
<svg>
|
||||
<CustomConnectionLine
|
||||
{...baseProps}
|
||||
{...lineProps}
|
||||
connectionStatus={args?.connectionStatus ?? "valid"}
|
||||
/>
|
||||
</svg>
|
||||
@@ -170,6 +194,17 @@ describe("CustomConnectionLine", () => {
|
||||
expect(path.getAttribute("d")).toContain("220");
|
||||
});
|
||||
|
||||
it("still resolves magnet target when fromHandle.type is missing", () => {
|
||||
renderLine({
|
||||
withMagnetHandle: true,
|
||||
omitFromHandleType: true,
|
||||
});
|
||||
|
||||
const path = getPath();
|
||||
expect(path.getAttribute("d")).toContain("300");
|
||||
expect(path.getAttribute("d")).toContain("220");
|
||||
});
|
||||
|
||||
it("strengthens stroke visual feedback while snapped", () => {
|
||||
renderLine();
|
||||
const idlePath = getPath();
|
||||
|
||||
Reference in New Issue
Block a user