fix(arrows): skip rendering empty label in SVG export#8137
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
5 Skipped Deployments
|
137c8ad to
1a6243f
Compare
1a6243f to
1b146ca
Compare
kaneel
approved these changes
Mar 4, 2026
Contributor
kaneel
left a comment
There was a problem hiding this comment.
Very nice explanations as to why it's a problem!
But the best answer – to me – as to why not rendering the text is that… it's empty!
So LGTM 🎉
mimecuvalo
approved these changes
Mar 4, 2026
steveruizok
approved these changes
Mar 4, 2026
Collaborator
|
nice one |
When exporting arrows without text labels, the label bounding box has zero dimensions. Subtracting ARROW_LABEL_PADDING from this produces negative width/height values that get passed to <foreignObject>, causing browser errors. Skip rendering RichTextSVG entirely when the label is empty, matching the existing guard in the canvas rendering path. Closes #7055
1b146ca to
58fb598
Compare
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #7055. When exporting arrows without text labels via
getSvgElement(), the<foreignObject>element receives negative width/height values (e.g.-8.5), causing browser console errors.The root cause is in
ArrowShapeUtil.toSvg(): it unconditionally renders aRichTextSVGfor the arrow label and applies.expandBy(-ARROW_LABEL_PADDING * scale)to shrink the bounds by padding. For empty labels,getArrowLabelPosition()returns a zero-sized box, so subtracting4.25 * 2 = 8.5produces negative dimensions.The fix skips rendering
RichTextSVGentirely when the label is empty, matching the existing guard in the canvas rendering path.Change type
bugfixTest plan
<foreignObject> attribute width: A negative value is not validerrorsRelease notes
<foreignObject>dimensions when arrows have no text labelNote
Low Risk
Low risk: a small conditional render change limited to SVG export output, with no impact on arrow geometry or editing behavior beyond avoiding invalid
<foreignObject>dimensions.Overview
Fixes arrow SVG export emitting invalid
<foreignObject>sizes when an arrow has no text label.ArrowShapeUtil.toSvg()now conditionally rendersRichTextSVGonly whenrichTextis non-empty, avoiding negative label bounds after padding is applied.Written by Cursor Bugbot for commit 58fb598. This will update automatically on new commits. Configure here.