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

[Yoga 3] Wrong outcome of max-height percentage value #1655

Open
1 task done
TheAdamBorek opened this issue May 17, 2024 · 1 comment
Open
1 task done

[Yoga 3] Wrong outcome of max-height percentage value #1655

TheAdamBorek opened this issue May 17, 2024 · 1 comment
Assignees

Comments

@TheAdamBorek
Copy link

Report

Issues and Steps to Reproduce

Description

In React Native app we set a wrapper height to 200% and then another wrapper gets max-height set to 50% (resulting in that {children} should have max "100%" size). We do that for pan gesture overflow & animations.

       {/* Represented as red rect beloew*/}
        <Animated.View style={[{
            width: "100%",
            height: "200%",
        }, [...]]}> 
              {/* Represented as orange rect below*/}
              <View style={{
                width: "100%",
                maxHeight: "50%",
              }}>
                   {/* Represented as yellow rect below*/}
                    {children}
                </View>
        </Animated.View>
    );

With recent update from "react-native": "0.73.4" -> "react-native": "0.74.1" we have noticed that {children} is 2 times smaller than it used to be.

Here's html screenshot illustrating the behaviour on web:

CleanShot 2024-05-17 at 14 04 15

  • Yoga fails to calculate the size for the orange rectangle.
  • Other rectangles are just there to mimic our React Native's <View /> setup
  • Source code of the html can be found below (as I've used it to yarn gentest)

Expected Behavior

Test to pass & to work the same as in html

Actual Behavior

Test fails
CleanShot 2024-05-17 at 13 49 45

yarn gentest sample

Here's the html sourcecode

<div id="max-height-2times-smaller-than-height-showcase" style="display: flex; flex-direction: row; gap: 50px">
    <div id="max-height-doesnt-work"
        style="height: 400px; width: 400px; padding-left: 10px; padding-right: 10px; border: black dashed 3px;">
        <div id="container" style="height: 200%; padding-left: 10px; padding-right: 10px; border: red dashed 3px;">
            <div id="parent"
                style="max-height: 50%; padding-left: 10px; padding-right: 10px; border: orange dashed 3px;">
                <div id="child"
                    style="height: 800px; padding-left: 10px; padding-right: 10px; border: yellow dashed 3px;">
                </div>
            </div>
        </div>
    </div>
    <div id="height-works-fine"
        style="height: 400px; width: 400px; padding-left: 10px; padding-right: 10px; border: black dashed 3px;">
        <div id="container-2" style="height: 200%; padding-left: 10px; padding-right: 10px; border: red dashed 3px;">
            <div id="parent-2" style="height: 50%; padding-left: 10px; padding-right: 10px; border: orange dashed 3px;">
                <div id="child-2"
                    style="height: 800px; padding-left: 10px; padding-right: 10px; border: yellow dashed 3px;">
                </div>
            </div>
        </div>
    </div>
    <div id="max-height-workaround"
        style="height: 400px; width: 400px; padding-left: 10px; padding-right: 10px; border: black dashed 3px;">
        <div id="container-3" style="height: 200%; padding-left: 10px; padding-right: 10px; border: red dashed 3px;">
            <div style="height: 100%; border: green dashed 3px;">
                <div id="parent-3"
                    style="max-height: 50%; padding-left: 10px; padding-right: 10px; border: orange dashed 3px;">
                    <div id="child-3"
                        style="height: 800px; padding-left: 10px; padding-right: 10px; border: yellow dashed 3px;">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@NickGerleman
Copy link
Contributor

Thanks for reporting this! I’m going to carve out some time to debug this, since it’s a new regression. I suspect this is related to changes made to fix maxHeight behavior for multiline containers.

@NickGerleman NickGerleman self-assigned this May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants