Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,22 @@ export class OutlineSegmentCandidatePointSolver extends BaseSolver {
Math.sign(this.outlineSegment[1].y - this.outlineSegment[0].y),
),
}
const viableBounds = {
let viableBounds = {
minX: largestRectBounds.minX - componentBounds.minX * segmentNormAbs.x,
minY: largestRectBounds.minY - componentBounds.minY * segmentNormAbs.y,
maxX: largestRectBounds.maxX - componentBounds.maxX * segmentNormAbs.x,
maxY: largestRectBounds.maxY - componentBounds.maxY * segmentNormAbs.y,
}

if (this.globalBounds) {
viableBounds = {
minX: Math.max(viableBounds.minX, this.globalBounds.minX),
minY: Math.max(viableBounds.minY, this.globalBounds.minY),
maxX: Math.min(viableBounds.maxX, this.globalBounds.maxX),
maxY: Math.min(viableBounds.maxY, this.globalBounds.maxY),
Comment on lines +172 to +184

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Intersecting with global bounds ignores component size

When global bounds are provided, viableBounds is intersected with those limits directly but without shrinking them by the component’s extents. For axes where segmentNormAbs is 0 (e.g., a vertical outline segment), the viable center range still spans the full largestRectBounds on that axis, so the resulting candidate can have its center at globalBounds.maxX or minX while the component’s body extends past the edge. If the user specifies tight board bounds, the solver will now generate placements that protrude outside the bounds even though it claims to respect them. Intersecting should subtract the component’s min/max offsets from this.globalBounds before clamping.

Useful? React with 👍 / 👎.

}
}

this.viableBounds = viableBounds

const viableBoundsWidth = viableBounds.maxX - viableBounds.minX
Expand Down
46 changes: 23 additions & 23 deletions tests/repros/__snapshots__/repro05.snap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.