Skip to content

Commit f831482

Browse files
authored
fix(flow): render connectors in Firefox (#553)
1 parent 4a8b992 commit f831482

3 files changed

Lines changed: 21 additions & 2 deletions

File tree

.changeset/fuzzy-flows-bow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@cloudflare/kumo": patch
3+
---
4+
5+
Fix Flow connector rendering in Firefox by emitting valid SVG path data without array commas and setting visible overflow on the SVG element attribute.

packages/kumo/src/components/flow/connectors.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ export function createRoundedPath(
9898

9999
const commands = [
100100
`M ${x1} ${y1}`,
101-
isBottom ? [...bottomCurveCommands] : [...topCurveCommands],
101+
...(isBottom ? bottomCurveCommands : topCurveCommands),
102102
`L ${pathEndX} ${y2}`,
103103
];
104104

@@ -144,7 +144,7 @@ export function createRoundedPath(
144144

145145
const commands = [
146146
`M ${x1} ${y1}`, // Move the cursor to the starting point
147-
isBottom ? [...bottomCurveCommands] : [...topCurveCommands],
147+
...(isBottom ? bottomCurveCommands : topCurveCommands),
148148
`L ${x2} ${pathEndY}`, // Draw the final line to the end point
149149
];
150150

@@ -158,6 +158,7 @@ export const Connectors = forwardRef<SVGSVGElement, ConnectorsProps>(
158158
<svg
159159
width="100%"
160160
height="100%"
161+
overflow="visible"
161162
aria-hidden="true"
162163
className="text-kumo-inactive overflow-visible"
163164
ref={svgRef}

packages/kumo/src/components/flow/flow.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,26 @@
11
import { describe, expect, it } from "vitest";
22
import { act, render, screen } from "@testing-library/react";
33
import { useState, useEffect } from "react";
4+
import { createRoundedPath } from "./connectors";
45
import { Flow } from "./index";
56

67
function shouldHaveIndex(element: Element, index: number) {
78
expect(element.getAttribute("data-node-index")).toBe(String(index));
89
}
910

1011
describe("Flow", () => {
12+
describe("connector paths", () => {
13+
it("serializes SVG path commands without array commas for Firefox", () => {
14+
const path = createRoundedPath(
15+
{ x1: 0, y1: 17, x2: 56, y2: 71 },
16+
{ orientation: "horizontal", single: false },
17+
);
18+
19+
expect(path).toBe("M 0 17 L 32 17 L 32 63 Q 32 71 40 71 L 48 71");
20+
expect(path).not.toContain(",");
21+
});
22+
});
23+
1124
describe("Compound component API", () => {
1225
it("exposes Node sub-component", () => {
1326
expect(Flow.Node).toBeDefined();

0 commit comments

Comments
 (0)