Skip to content

Commit

Permalink
Clamp ruler marker resize offset line position (#6700)
Browse files Browse the repository at this point in the history
**Problem:**

While resizing via the ruler markers the offset line should not be
allowed to go past the grid container bounds.

**Fix:**

Clamp the `top` and `left` props of the line based on the container.

Fixes #6699
  • Loading branch information
ruggi authored and liady committed Dec 13, 2024
1 parent 08ba147 commit 962a4aa
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions editor/src/components/canvas/controls/grid-controls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import type { CanvasPoint, CanvasRectangle, LocalRectangle } from '../../../core
import {
boundingRectangleArray,
canvasPoint,
clamp,
isFiniteRectangle,
isInfinityRectangle,
nullIfInfinity,
Expand Down Expand Up @@ -2606,14 +2607,21 @@ const ResizeOffsetLine = React.memo(
}
const isColumn = props.edge === 'column-start' || props.edge === 'column-end'

const top = isColumn
? props.container.y
: clamp(props.container.y, props.container.y + props.container.height, props.drag.y)
const left = !isColumn
? props.container.x
: clamp(props.container.x, props.container.x + props.container.width, props.drag.x)

return (
<div
style={{
position: 'absolute',
width: isColumn ? 1 : props.container.width,
height: !isColumn ? 1 : props.container.height,
top: isColumn ? props.container.y : props.drag.y,
left: !isColumn ? props.container.x : props.drag.x,
top: top,
left: left,
borderLeft: isColumn ? `1px dashed ${colorTheme.primary.value}` : undefined,
borderTop: !isColumn ? `1px dashed ${colorTheme.primary.value}` : undefined,
}}
Expand Down

0 comments on commit 962a4aa

Please sign in to comment.