fix(container): minSize should not add children's sizes, but take max instead
Some checks failed
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 57s

This commit is contained in:
2025-11-28 14:34:32 +01:00
parent 41229c13d3
commit f7025a0fc2

View File

@@ -907,7 +907,7 @@ pub fn Container(Model: type, Event: type) type {
}
pub fn minSize(this: *const @This(), model: *const Model, size: Point) Point {
var min_size = this.element.minSize(model, size);
var min_size: Point = .{};
for (this.elements.items) |child| {
const child_size = child.minSize(model, child.properties.size.dim);
min_size = switch (this.properties.layout.direction) {
@@ -921,7 +921,11 @@ pub fn Container(Model: type, Event: type) type {
},
};
}
return min_size;
const element_size = this.element.minSize(model, size);
return .{
.x = @max(element_size.x, min_size.x),
.y = @max(element_size.y, min_size.y),
};
}
pub fn handle(this: *const @This(), model: *Model, event: Event) !void {