Skip to content

Fix HUG sizing collapsing to FIXED for TEXT nodes - #262

Open
heinvv wants to merge 1 commit into
bernaferrari:mainfrom
AtomicStudioAI:fix/hug-sizing-collapses-to-fixed-for-text
Open

Fix HUG sizing collapsing to FIXED for TEXT nodes#262
heinvv wants to merge 1 commit into
bernaferrari:mainfrom
AtomicStudioAI:fix/hug-sizing-collapses-to-fixed-for-text

Conversation

@heinvv

@heinvv heinvv commented Aug 18, 2026

Copy link
Copy Markdown

Fixes #261.

TEXT nodes never have a children array — their content is characters, a string, not child
elements. 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 without
a live Figma document, and made it explicitly false for TEXT regardless of children.

Small, self-contained diff — just this one function and its test, nothing else.

Summary by CodeRabbit

  • Bug Fixes

    • Improved layout conversion for text elements using HUG sizing.
    • Prevented meaningful text content from being incorrectly converted to FIXED sizing.
    • Empty non-text elements now receive the appropriate fallback sizing.
  • Tests

    • Added coverage for text nodes, empty elements, and elements containing children.

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.
@vercel

vercel Bot commented Aug 18, 2026

Copy link
Copy Markdown

@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.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: c6bc486b-cb19-46ef-bea8-5349366861ea

📥 Commits

Reviewing files that changed from the base of the PR and between f5c4831 and 96cecbc.

📒 Files selected for processing (2)
  • packages/backend/src/altNodes/jsonNodeConversion.test.ts
  • packages/backend/src/altNodes/jsonNodeConversion.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The conversion now preserves HUG sizing for TEXT nodes. It converts empty non-text nodes to FIXED sizing and adds tests for the helper behavior.

Changes

HUG sizing conversion

Layer / File(s) Summary
Sizing fallback and validation
packages/backend/src/altNodes/jsonNodeConversion.ts, packages/backend/src/altNodes/jsonNodeConversion.test.ts
The exported hugSizingIsMeaningless helper treats TEXT nodes as meaningful and empty non-text nodes as meaningless. Horizontal and vertical HUG fallbacks use the helper. Tests cover text nodes, empty frames, and frames with children.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 96cec

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)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the fix for TEXT nodes whose HUG sizing was incorrectly converted to FIXED.
Linked Issues check ✅ Passed The changes preserve HUG sizing for TEXT nodes and retain FIXED fallback behavior for empty non-text frames, satisfying issue #261.
Out of Scope Changes check ✅ Passed The implementation and unit tests directly support issue #261 and contain no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HUG-sized TEXT nodes get forced to a fixed pixel width

1 participant