Layout problem related flex #892

Open
opened 2019-05-07 00:28:39 -07:00 by wqyfavor · 0 comments
wqyfavor commented 2019-05-07 00:28:39 -07:00 (Migrated from github.com)

Report

Issues and Steps to Reproduce

Replaces this with steps to repro your issue.

Using such code to test.

const YGConfigRef config = YGConfigNew();

const YGNodeRef root = YGNodeNewWithConfig(config);
YGNodeStyleSetWidth(root, 750);

const YGNodeRef root_child0 = YGNodeNewWithConfig(config);
YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 0);
// I want root_child0 to layout its children horizontally and expand itself to 2 * 750 width
YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow);
YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute);
YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0);
YGNodeInsertChild(root, root_child0, 0);

const YGNodeRef root_child1= YGNodeNewWithConfig(config);
YGNodeStyleSetFlex(root_child1, 1);
YGNodeStyleSetWidth(root_child1, 750);
YGNodeInsertChild(root_child0, root_child1, 0);

const YGNodeRef root_child2= YGNodeNewWithConfig(config);
YGNodeStyleSetFlex(root_child2, 1);
YGNodeStyleSetWidth(root_child2, 750);
YGNodeInsertChild(root_child0, root_child2, 0);

YGNodeCalculateLayout(root, 750, 2000, YGDirectionLTR);

printf("w root_child0: %f", YGNodeLayoutGetWidth(root_child0));

YGNodeFreeRecursive(root);
YGConfigFree(config);

Expected Behavior

Describe what you expected would happen.

Width of root_child0 after layout should be 2 * 750

Actual Behavior

Describe what actually happened.

Width of root_child0 after layout is 0.

If I didn't set flex to 1 for root_child1 and root_child2, the layout would be correct. But on browser, with or without flex to 1, width of root_child0 is always 2 * 750.

Link to Code

If you have some code that maintainers can clone/test for themselves, bugs can be resolved much faster. Please paste a link here.

When applicable, use this fiddle to post a web repro.

# Report - [ ] I have searched [existing issues](https://github.com/facebook/yoga/issues) and this is not a duplicate # Issues and Steps to Reproduce ***Replaces this with steps to repro your issue.*** Using such code to test. const YGConfigRef config = YGConfigNew(); const YGNodeRef root = YGNodeNewWithConfig(config); YGNodeStyleSetWidth(root, 750); const YGNodeRef root_child0 = YGNodeNewWithConfig(config); YGNodeStyleSetPosition(root_child0, YGEdgeBottom, 0); // I want root_child0 to layout its children horizontally and expand itself to 2 * 750 width YGNodeStyleSetFlexDirection(root_child0, YGFlexDirectionRow); YGNodeStyleSetPositionType(root_child0, YGPositionTypeAbsolute); YGNodeStyleSetPosition(root_child0, YGEdgeTop, 0); YGNodeInsertChild(root, root_child0, 0); const YGNodeRef root_child1= YGNodeNewWithConfig(config); YGNodeStyleSetFlex(root_child1, 1); YGNodeStyleSetWidth(root_child1, 750); YGNodeInsertChild(root_child0, root_child1, 0); const YGNodeRef root_child2= YGNodeNewWithConfig(config); YGNodeStyleSetFlex(root_child2, 1); YGNodeStyleSetWidth(root_child2, 750); YGNodeInsertChild(root_child0, root_child2, 0); YGNodeCalculateLayout(root, 750, 2000, YGDirectionLTR); printf("w root_child0: %f", YGNodeLayoutGetWidth(root_child0)); YGNodeFreeRecursive(root); YGConfigFree(config); # Expected Behavior ***Describe what you expected would happen.*** Width of root_child0 after layout should be 2 * 750 # Actual Behavior ***Describe what actually happened.*** Width of root_child0 after layout is 0. If I didn't set flex to 1 for root_child1 and root_child2, the layout would be correct. But on browser, with or without flex to 1, width of root_child0 is always 2 * 750. # Link to Code ***If you have some code that maintainers can clone/test for themselves, bugs can be resolved much faster. Please paste a link here.*** ***When applicable, use this [fiddle](https://jsfiddle.net/emilsjolander/jckmwztt/) to post a web repro.***
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DaddyFrosty/yoga#892
No description provided.