diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index d2085d4fb49..16217e8511d 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -181,6 +181,16 @@ impl Label { let pos = pos2(ui.max_rect().left(), ui.cursor().top()); assert!(!galley.rows.is_empty(), "Galleys are never empty"); + + // set the row height to ensure the cursor advancement is correct. when creating a child ui such as with + // ui.horizontal_wrapped, the initial cursor will be set to the height of the child ui. this can lead + // to the cursor not advancing to the second row but rather expanding the height of the cursor. + // + // note that we do not set the row height earlier in this function as we do want to allow populating + // `first_row_min_height` above. however it is crucial the placer knows the actual row height by + // setting the cursor height before ui.allocate_rect() gets called. + ui.set_row_height(galley.rows[0].height()); + // collect a response from many rows: let rect = galley.rows[0].rect.translate(vec2(pos.x, pos.y)); let mut response = ui.allocate_rect(rect, sense);