fix(dom): measureTextNode returns natural in Undefined mode (A1+A5 / #51 #58)#89
Merged
Conversation
Co-Authored-By: Mark <psyhik17@gmail.com> Co-Authored-By: Claude <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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 #51 (A1) and #58 (A5).
Summary
measureTextNode(the yoga measureFunc bound to everyink-textnode) used to callwrapTexteven when yoga asked for intrinsic size — i.e.widthMode === Undefinedwithwidth = NaN. With'truncate'it appended an ellipsis to the natural text and reportednatural + 1; with'truncate-start'it collapsed the entire string to a single"…"cell. That bogus width became the flex basis and cascaded into all kinds of downstream weirdness (silent truncation, surprise wrapping, layout assumptions that don't hold).The fix is a single early return: in Undefined mode, skip wrap/truncate entirely and report the natural dimensions. Wrap and truncate are about fitting within an ACTUAL constraint; without one, the natural size is the only honest answer.
Why this is the right level
if (text.includes('\n') && widthMode === Undefined) return naturalbranch was the same invariant for a narrower case (multiline content). It's now subsumed by the general rule.render-node-to-output.ts) already engages whenwidestLine(plainText) > maxWidth— the truth source for fit-or-overflow stays there. Nothing changes about how text is displayed once layout has a real constraint.Test plan
dom.test.ts— 9 unit tests of the Undefined / AtMost / Exactly contract, including the A1 ellipsis-poisoning bug and the truncate-start "whole string → '…'" pathology.render-node-to-output.test.ts— 8 nested-text integration tests covering the issue Nested <Text> inside flex-row parent silently truncates trailing content even with abundant slack #51 repro (row parent, abundant slack), narrower widths down to exact fit, the column-parent A1 path (where the Undefined-mode call actually fires), the truncate-start render path, and a cross-stretch column scenario.Commits
40d97c4test(render): pin nested-text + flex-row good-path behavior (Nested <Text> inside flex-row parent silently truncates trailing content even with abundant slack #51)a412ce1test(dom): failing tests for measureTextNode Undefined-mode invariant (Nested <Text> inside flex-row parent silently truncates trailing content even with abundant slack #51, A5:<Text>always carriesflexShrink: 1on wrap-family modes #58)9224140fix(dom): measureTextNode returns natural in Undefined mode (closes Nested <Text> inside flex-row parent silently truncates trailing content even with abundant slack #51, A5:<Text>always carriesflexShrink: 1on wrap-family modes #58)d5d8789test(render): column-parent + cross-stretch scenarios for nested text (Nested <Text> inside flex-row parent silently truncates trailing content even with abundant slack #51, A5:<Text>always carriesflexShrink: 1on wrap-family modes #58)554b771docs: note Undefined-mode measureTextNode invariant (Nested <Text> inside flex-row parent silently truncates trailing content even with abundant slack #51, A5:<Text>always carriesflexShrink: 1on wrap-family modes #58)