Ensure canvas dimensions are integers (#64949)

This commit is contained in:
Grzegorz Zdunek
2026-03-24 08:33:24 +00:00
committed by GitHub
parent 3b10cc2b18
commit 08f9670402
@@ -103,7 +103,13 @@ export const CanvasRenderer = forwardRef<
canvas.getContext('2d').clearRect(0, 0, canvas.width, canvas.height);
},
focus: () => canvasRef.current.focus(),
getSize: () => canvasRef.current.getBoundingClientRect(),
getSize: () => {
const rect = canvasRef.current.getBoundingClientRect();
return {
height: Math.round(rect.height),
width: Math.round(rect.width),
};
},
};
}, []);
@@ -120,8 +126,8 @@ export const CanvasRenderer = forwardRef<
const observer = new ResizeObserver(([entry]) => {
if (entry && entry.contentRect.height !== 0) {
debouncedOnResize({
height: entry.contentRect.height,
width: entry.contentRect.width,
height: Math.round(entry.contentRect.height),
width: Math.round(entry.contentRect.width),
});
}
});