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

maxWidth with YGPercentValue doesn't work properly in YGFlexDirectionRow container #611

Closed
kostiadombrovsky opened this issue Jul 28, 2017 · 2 comments

Comments

@kostiadombrovsky
Copy link

kostiadombrovsky commented Jul 28, 2017

Issues and Steps to Reproduce

maxWidth constraint is applied twice when measuring a view YGNodeBoundAxisWithinMinAndMax resolves max value with axisSize but axisSize was already constrained to the specified maxWidth value. So it basically does it twice.

  1. Set maxWidth toYGPercentValue on the second view in a YGFlexDirectionRow container
  2. Observe incorrect layout

Expected Behavior

Expected for the second subview in the example to be at most half its superview size.

Actual Behavior

The second subview in the example is 1/4 of the size.

Link to Code

                UIView *line1 = [[UIView alloc] init];
                [line1 configureLayoutWithBlock:^(YGLayout *layout) {
                    layout.enabled = YES;
                    layout.flexDirection = YGFlexDirectionRow;
                    layout.justifyContent = YGJustifySpaceBetween;
                    layout.alignItems = YGAlignCenter;
                    layout.paddingTop = YGPointValue(UBECardInfoViewTitleLabelMargins.top);
                }];
                line1.backgroundColor = [UBColor whiteColor];

                [self.titleLabel configureLayoutWithBlock:^(YGLayout *layout) {
                    layout.enabled = YES;
                }];
                [line1 addSubview:self.titleLabel];

                [self.subtitleLabel configureLayoutWithBlock:^(YGLayout *layout) {
                    layout.enabled = YES;
                    layout.marginTop = YGPointValue(2.0f);
                    layout.marginLeft = YGPointValue(UBEFeedItemCardCellDefaultMargin);
                    layout.maxWidth = YGPercentValue(50.0f);
                }];
                [line1 addSubview:self.subtitleLabel];
                [self insertSubview:line1 atIndex:0];
@kostiadombrovsky kostiadombrovsky changed the title ma maxWidth with YGPercentValue doesn't work properly in YGFlexDirectionRow container Jul 28, 2017
@woehrl01
Copy link
Contributor

woehrl01 commented Oct 9, 2017

Hi @kostiadombrovsky .

I tried to reproduce, but this works for me, the size is correctly 60px wide:

<div id="percent_sub_child" style="width: 120px; height: 20px; flex-direction: row; justify-content: space-between; align-items: center;">
  <div></div>
  <div style="margin-top: 2px; margin-left: 5px; max-width: 50%">
    <div style="width: 80px"></div>
  </div>
</div>

could you please provide a more complete repro?

@woehrl01
Copy link
Contributor

woehrl01 commented Oct 9, 2017

Sorry @kostiadombrovsky , found the problem! I pushed a PR at #649 . Thank you for the report.

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