Skip to content

Commit 8be7680

Browse files
committed
fix: work around Chromium addPath + roundRect evenodd bug
Path2D.addPath() with a roundRect sub-path breaks the evenodd fill rule in Chromium, causing padding and margin ring fills to render as empty. Build both sub-paths directly on the same Path2D instead. Extract appendBoundsToPath as the shared primitive so buildBoundsPath and buildRingPath both delegate to it without duplicating logic.
1 parent a481586 commit 8be7680

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

packages/react-grab/src/components/overlay-canvas.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -329,23 +329,30 @@ export const OverlayCanvas: Component<OverlayCanvasProps> = (props) => {
329329
return pattern;
330330
};
331331

332-
const buildBoundsPath = (animation: AnimatedBounds): Path2D => {
332+
// Chromium bug: combining a roundRect sub-path via addPath() breaks the
333+
// "evenodd" fill rule, rendering the ring as empty. We must draw both
334+
// sub-paths directly on the same Path2D instead of using addPath().
335+
const appendBoundsToPath = (path: Path2D, animation: AnimatedBounds) => {
333336
const { x, y, width, height } = animation.current;
334-
const path = new Path2D();
335-
if (width <= 0 || height <= 0) return path;
337+
if (width <= 0 || height <= 0) return;
336338
const clampedRadius = Math.min(animation.borderRadius, width / 2, height / 2);
337339
if (clampedRadius > 0) {
338340
path.roundRect(x, y, width, height, clampedRadius);
339341
} else {
340342
path.rect(x, y, width, height);
341343
}
344+
};
345+
346+
const buildBoundsPath = (animation: AnimatedBounds): Path2D => {
347+
const path = new Path2D();
348+
appendBoundsToPath(path, animation);
342349
return path;
343350
};
344351

345352
const buildRingPath = (outer: AnimatedBounds, inner: AnimatedBounds): Path2D => {
346353
const path = new Path2D();
347-
path.addPath(buildBoundsPath(outer));
348-
path.addPath(buildBoundsPath(inner));
354+
appendBoundsToPath(path, outer);
355+
appendBoundsToPath(path, inner);
349356
return path;
350357
};
351358

0 commit comments

Comments
 (0)