Fix HUG sizing collapsing to FIXED for TEXT nodes - #262
Conversation
A TEXT node never has a children array — its content is `characters`, a string, not child elements. The "HUG with nothing to hug falls back to FIXED" check read that absence as "nothing to hug" and forced every HUG-sized text node to FIXED, baking in whatever pixel width the text happened to render at in the source file. That width then breaks the moment surrounding layout differs from that original context (a different viewport, different sibling content, a wrapped label). Extracted the check into hugSizingIsMeaningless() so it's unit-testable without a live Figma document, and made it explicitly false for TEXT regardless of children.
|
@heinvv is attempting to deploy a commit to the bernaferrari's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe conversion now preserves HUG sizing for TEXT nodes. It converts empty non-text nodes to FIXED sizing and adds tests for the helper behavior. ChangesHUG sizing conversion
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change corrects HUG sizing for TEXT nodes and includes focused tests; no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Fixes #261.
TEXT nodes never have a
childrenarray — their content ischaracters, a string, not childelements. The existing "HUG with nothing to hug falls back to FIXED" check read that absence as
"nothing to hug" and forced every HUG-sized text node to FIXED, baking in whatever pixel width the
text happened to render at during conversion.
Extracted the check into
hugSizingIsMeaningless()(exported, unit-tested) so it's testable withouta live Figma document, and made it explicitly
falsefor TEXT regardless ofchildren.Small, self-contained diff — just this one function and its test, nothing else.
Summary by CodeRabbit
Bug Fixes
Tests