Skip to content

Commit

Permalink
Fix grid info for empty grid (#782)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevennovaryo authored Jan 8, 2025
1 parent 177d645 commit e353c14
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/compute/grid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,17 @@ pub fn compute_grid_layout<Tree: LayoutGridContainer>(
}
});

// Set detailed grid information
#[cfg(feature = "detailed_layout_info")]
tree.set_detailed_grid_info(
node,
DetailedGridInfo {
rows: DetailedGridTracksInfo::from_grid_tracks_and_track_count(final_row_counts, rows),
columns: DetailedGridTracksInfo::from_grid_tracks_and_track_count(final_col_counts, columns),
items: items.iter().map(DetailedGridItemsInfo::from_grid_item).collect(),
},
);

// If there are not items then return just the container size (no baseline)
if items.is_empty() {
return LayoutOutput::from_outer_size(container_border_box);
Expand Down Expand Up @@ -609,16 +620,6 @@ pub fn compute_grid_layout<Tree: LayoutGridContainer>(
item.y_position + item.baseline.unwrap_or(item.height)
};

#[cfg(feature = "detailed_layout_info")]
tree.set_detailed_grid_info(
node,
DetailedGridInfo {
rows: DetailedGridTracksInfo::from_grid_tracks_and_track_count(final_row_counts, rows),
columns: DetailedGridTracksInfo::from_grid_tracks_and_track_count(final_col_counts, columns),
items: items.iter().map(DetailedGridItemsInfo::from_grid_item).collect(),
},
);

LayoutOutput::from_sizes_and_baselines(
container_border_box,
item_content_size_contribution,
Expand Down

0 comments on commit e353c14

Please sign in to comment.