Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test util to measure text properly based on flex direction #1768

Closed
wants to merge 1 commit into from

Conversation

joevilches
Copy link
Contributor

Summary: Depending on the flex direction text will either be capped to the measured size or to the longest word, so I added that functionality

Differential Revision: D67106199

Copy link

vercel bot commented Dec 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
yoga-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 11, 2024 9:40pm

Summary: Depending on the flex direction text will either be capped to the measured size or to the longest word, so I added that functionality

Differential Revision: D67106199
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67106199

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D67106199

@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 909e4be.

@nicoburns
Copy link
Contributor

nicoburns commented Dec 15, 2024

@joevilches I don't think this is right. I believe the measure function should still return the size floored by the longest word size, but the parent container should override that size due to the max-width style (which probably is different for flexbox row vs. column due to Flexbox having a weird quirk of not applying min/max sizes to children when determining the flex base size in the main axis). As a general principle, the min- or max- content size of box is never affected by the parent's display mode (although the resultant size of the box may be).

@joevilches
Copy link
Contributor Author

@nicoburns that makes sense thanks for commenting. I am curious how Yoga would yield the same results as chrome in this case, since it did seem like at some point we would need to measure with some smaller width than the longest word to get the correct height. I can take a look again, maybe the issue is something else.

@nicoburns
Copy link
Contributor

@joevilches I think I previously misunderstood this code (not helped by the fact I was trying to read it on my phone!). The width you are using does seem broadly correct to me with default styles. Although the way we deal with this in Taffy is by using (what Yoga calls) an "Exact" sizing constraint in the column case (depending on align-items)

I think the reason this is (/seems to be) different for columns vs. rows is because align-items defaults to stretch. Which will mean that with default styles the min-content width will overridden for a column. I believe this wouldn't apply with align-items overridden to start or similar.

The following HTML:

<div style="display: flex;width: 50px;flex-direction: column;">
        <div>
            orheg irehg ireh girehg iorhioh iroegh 
            jhnreuighuirebghuierhguierbuigbreuibuebgiuerbgiuberuigberuibguirebg
            righierhg ihe irogh eriohg iorehg ioerhg iorehg 
        </div>
</div>

Results in:

Screenshot 2024-12-24 at 14 19 23

But if you add an align-items: start style to the outer div then you get:

Screenshot 2024-12-24 at 14 19 13

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

Successfully merging this pull request may close these issues.

3 participants