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

flex with non flex wraper do not respect children size #1787

Open
MateWW opened this issue Feb 14, 2025 · 1 comment
Open

flex with non flex wraper do not respect children size #1787

MateWW opened this issue Feb 14, 2025 · 1 comment

Comments

@MateWW
Copy link

MateWW commented Feb 14, 2025

Hello,

I've noticed discrepancy between yoga and web(chrome and safari tested) behaviour.

Its very easy to notice that on snack
https://snack.expo.dev/@matew/yoga-rendering-issue

iOS Android Web
Image Image Image

Summary

To make it easier lets assume the following:
container - is the first component with no height and flex set
flex wrapper - is container child which has flex set and border defined
static component - is flex wrapper child which has static size (50x50)

As you may notice on above screenshot for mobile devices border applied on
flex wrapper is just squeezed and overlaps with static component

In that situation yoga set that flex wrapper size to 0 while on web
it respect that there is available space and static component has defined size.

How web supports when there is no enough space?

I've created a snack which helps to illustrate how it works on web
https://snack.expo.dev/@matew/eager-yellow-tortilla

Screen shoot ![Image](https://github.com/user-attachments/assets/54106c9f-1c35-4cd1-b3bf-7bd7e5e3e8b4)
@NickGerleman
Copy link
Contributor

Yoga/RN has documented behavior where flex: 1 unlike web means flexGrow: 1, flexShrink: 1. You will see same behavior if you set this in web.

This is super weird behavior, that RN web does not try to emulate, but around forever. UseWebDefaults in Yoga IIRC changes this, but has its own wide set of problems, because it doesn't set everything to web defaults, because the flag was added before Yoga supported many of these defaults (not very forward looking...).

Would recommend using flexGrow and flexShrink explicitly.

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

No branches or pull requests

2 participants