fix(draw): prevent zero scaleX/scaleY on draw and highlight shapes#8067
fix(draw): prevent zero scaleX/scaleY on draw and highlight shapes#8067
Conversation
When resizing a draw or highlight shape to zero width or height, Box.Resize returns scaleX=0 or scaleY=0. Multiplying this into the shape's scaleX/scaleY props produces 0, which violates the nonZeroFiniteNumber validator and throws a ValidationError. Closes #7997 Co-authored-by: Cursor <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
Co-authored-by: Cursor <[email protected]>
|
Hey! 👋 This PR contains changes to Here's an example: Once you add this section, the check will pass automatically! |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
|
|
||
| override onResize(shape: TLDrawShape, info: TLResizeInfo<TLDrawShape>) { | ||
| const { scaleX, scaleY } = info | ||
| if (scaleX === 0 || scaleY === 0) return |
There was a problem hiding this comment.
Resize ignores other axis when collapsed
Medium Severity
onResize now returns undefined when either info.scaleX or info.scaleY is 0, which drops the non-zero axis resize too. If a resize produces { scaleX: 0, scaleY: 2 } (or vice versa), the shape becomes a full no-op instead of applying the valid axis while preserving the existing scale on the collapsed axis.
Additional Locations (1)
Co-authored-by: Cursor <[email protected]>
Add 12 new entries from PRs merged since v4.4.0: - Featured: click-through on transparent image pixels (#7942) - API: enum-to-const-object refactor (#8084) - Improvements: SVG sanitizer (#7896), save-on-blur (#8037) - Bug fixes: cross-origin download (#8090), zero-size draw (#8067), rich text toolbar cleanup (#8050), zoom threshold (#8040), selection foreground fallback (#8011), sticky note SVG shadow (#7934), arrow frame clamping (#7932), zero pressure draw (#5693)


Closes #7997
When resizing a draw or highlight shape to zero width or height,
Box.ResizereturnsscaleX=0orscaleY=0. TheonResizehandlers inDrawShapeUtilandHighlightShapeUtilmultiplied this directly into the shape'sscaleX/scaleYprops, producing 0, which violates thenonZeroFiniteNumbervalidator and throws aValidationError.This PR guards against that by keeping the existing scale value when the computed result would be 0.
Change type
bugfixTest plan
Release notes
Made with Cursor
Note
Low Risk
Small, localized guard in resize logic plus tests; behavior only changes for the edge case of collapsing a shape to zero size.
Overview
Prevents
DrawShapeUtilandHighlightShapeUtilfrom applying a resize operation that would result inscaleXorscaleYbecoming0; theonResizehandler now returnsundefined(no-op) in that case.Adds unit coverage for
DrawShapeUtilto ensure resizing to zero width/height leaves scale unchanged and that negative scale (flipping) is preserved. Updates the generated API report to reflect the newonResizereturn type ({ props: ... } | undefined).Written by Cursor Bugbot for commit 2738894. This will update automatically on new commits. Configure here.