Skip to content

revert: "feat(text): expose trimmedHeight on text nodes (#30)"#35

Merged
chiefcll merged 1 commit into
mainfrom
revert/trimmed-height
May 23, 2026
Merged

revert: "feat(text): expose trimmedHeight on text nodes (#30)"#35
chiefcll merged 1 commit into
mainfrom
revert/trimmed-height

Conversation

@chiefcll
Copy link
Copy Markdown
Contributor

Summary

Reverts #30. Removes the node.trimmedHeight getter, the trimmedHeight field on the loaded event payload, and the supporting calc in both renderers.

This reverts commit 965999b282851938f0a73ccd288acbf32350e2c7 exactly — 5 files, 69 deletions, mechanical inverse.

Why

trimmedHeight was introduced as a way for callers to tightly size a text node to its visible ink — e.g. node.h = payload.trimmedHeight after loaded so flexbox alignItems: 'center' would optically center the glyphs.

Investigation found two problems with the API as shipped:

  1. The documented snippet doesn't work. set h() on CoreTextNode is overridden to set maxHeight instead of props.h — so node.h = payload.trimmedHeight is silently rewritten to node.maxHeight = trimmedHeight, which is a layout constraint, not a dimension. Result: a wasted re-layout invalidation, no change to the visible bounding box, and (worse) lines silently dropped when maxHeight < 2 × lineHeightPx.

  2. It's the wrong tool for centering anyway. With the default textBaselineMode: 'optical' (or 'cap', or 'x'), the math already places the optical center of the text at lineHeightPx / 2 = node.h / 2. Dropping a text node into a parent and using mountY: 0.5 already perfectly centers the visible ink — no trimmedHeight needed, no API surface required.

For the rarer case of "I want the node's box to hug the ink" (tight chips/badges in a flex row), the right shape is a dedicated textBoxTrim prop modeled after CSS text-box-trim — explicit, declarative, and it can actually update the texture/baselines coherently. That's a future addition; not in this PR.

What stays

Nothing else from #30 had external users that we could find — grep for trimmedHeight after this revert returns no matches in src/, examples/tests/, or test/. Safe removal.

Test plan

  • CI green (pnpm build, pnpm test, visual regression)
  • Manual: existing text examples render identically (the renderer-internal value was never used by anything except the public getter/event)

🤖 Generated with Claude Code

@chiefcll chiefcll merged commit 95f0f91 into main May 23, 2026
1 check passed
@chiefcll chiefcll deleted the revert/trimmed-height branch May 23, 2026 22:56
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.

1 participant