Skip to content

Commit

Permalink
Fix intrinsic sizing min size (#723)
Browse files Browse the repository at this point in the history
* Add failing test

* Fix bug
  • Loading branch information
nicoburns authored Oct 22, 2024
1 parent b92dcec commit 84ab995
Show file tree
Hide file tree
Showing 4 changed files with 315 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/compute/flexbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,9 @@ fn determine_container_main_size(
.iter()
.map(|child| {
let padding_border_sum = (child.padding + child.border).main_axis_sum(constants.dir);
(child.flex_basis + child.margin.main_axis_sum(constants.dir)).max(padding_border_sum)
(child.flex_basis.maybe_max(child.min_size.main(constants.dir))
+ child.margin.main_axis_sum(constants.dir))
.max(padding_border_sum)
})
.sum::<f32>();
total_target_size + line_main_axis_gap
Expand All @@ -924,7 +926,9 @@ fn determine_container_main_size(
.iter()
.map(|child| {
let padding_border_sum = (child.padding + child.border).main_axis_sum(constants.dir);
(child.flex_basis + child.margin.main_axis_sum(constants.dir)).max(padding_border_sum)
(child.flex_basis.maybe_max(child.min_size.main(constants.dir))
+ child.margin.main_axis_sum(constants.dir))
.max(padding_border_sum)
})
.sum::<f32>();
total_target_size + line_main_axis_gap
Expand Down
21 changes: 21 additions & 0 deletions test_fixtures/grid/grid_taffy_issue_591.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script src="../../scripts/gentest/test_helper.js"></script>
<link rel="stylesheet" type="text/css" href="../../scripts/gentest/test_base_style.css">
<title>
Test description
</title>
</head>
<body style="margin: 20px;">

<div id="test-root" style="display: flex; width: 300px; height: 200px;">
<div id="outer" style="display: flex; position: absolute; top: 0; left: 0; max-width: 100px; max-height: 100px; padding: 10px; align-items: center; justify-content: center;">
<div id="inner" style="display: flex; min-width: 50px; min-height: 50px; padding: 10px;"></div>
</div>
</div>

</body>
</html>


284 changes: 284 additions & 0 deletions tests/generated/grid/grid_taffy_issue_591.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/generated/grid/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 84ab995

Please sign in to comment.