CheckList
Version
7.1.0
In What environments are you experiencing the problem?
Chrome
Node Version (if applicable)
22.1.0
Link To Reproduction
https://codesandbox.io/p/sandbox/h2nlfp
Steps To Reproduce
- Load an SVG that declares width="1486" height="1080" and viewBox="0 0 1486 1080", but contains geometry that extends outside the viewBox (overflow that is hidden in browser rendering).
- Import using Fabric v7 loadSVGFromURL / loadSVGFromString.
- Create a group from returned objects (either fabric.util.groupSVGElements(objects, options) or new fabric.Group(objects)).
- Observe:
-
- The resulting Fabric group has larger width/height than the SVG viewport (e.g. ~2156×1359 instead of 1486×1080).
-
- Parts of the SVG that are hidden/clipped in browser become visible or affect bounding/selection.
Minimal code:
const { objects, options } = await fabric.loadSVGFromURL(svgURL);
const group = new fabric.Group(objects); // also reproducible with groupSVGElements(objects, options)
console.log("SVG declared:", options.width, options.height, options.viewBoxWidth, options.viewBoxHeight);
console.log("Fabric group:", group.width, group.height);
// Add to canvas
canvas.add(group);
canvas.setActiveObject(group);
canvas.requestRenderAll();
Expected Behavior
-
Imported SVG group dimensions should match the SVG viewport/viewBox (or at least provide an option to):
- treat SVG bounds as the viewBox/width/height
- clip overflow consistently with browser SVG viewport behavior
-
Hidden overflow content (outside viewBox / clipped in browser) should not:
- expand Fabric object bounding boxes
- become visible unexpectedly
-
Scaling/centering based on SVG width/height/viewBox should produce a correct bounding box aligned with visible content.
Actual Behavior
- Fabric v7 produces a group bounding box larger than the SVG declared size:
- SVG: 1486×1080
- Fabric group: around 2156×1359
- Because bounds are larger than visible viewport, scaling-to-fit using group bounds makes visible artwork appear smaller than expected inside its bounding box.
- Additionally, content that is hidden/clipped in browser SVG rendering can appear or contribute to bounding box calculations in Fabric.
SVG

ISSUE

Error Message & Stack Trace
None (no thrown error). This is a rendering / bounds calculation issue.
CheckList
Version
7.1.0
In What environments are you experiencing the problem?
Chrome
Node Version (if applicable)
22.1.0
Link To Reproduction
https://codesandbox.io/p/sandbox/h2nlfp
Steps To Reproduce
Minimal code:
Expected Behavior
Imported SVG group dimensions should match the SVG viewport/viewBox (or at least provide an option to):
Hidden overflow content (outside viewBox / clipped in browser) should not:
Scaling/centering based on SVG width/height/viewBox should produce a correct bounding box aligned with visible content.
Actual Behavior
SVG

ISSUE

Error Message & Stack Trace