diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 48865a6ff78e..e95f56a49c7c 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -763,9 +763,9 @@ impl Prepared { } // Restore scroll target (if any) meant for ScrollAreas up the stack - for d in 0..2 { - if saved_scroll_target[d].is_some() { - ui.ctx().frame_state_mut(|state| { + ui.ctx().frame_state_mut(|state| { + for d in 0..2 { + if saved_scroll_target[d].is_some() { state.scroll_target[d] = saved_scroll_target[d]; }); }