From 2a020d6bc72c838039f5d1fc44291612c4818f4c Mon Sep 17 00:00:00 2001 From: Antoine Beyeler Date: Fri, 15 Mar 2024 16:32:11 +0100 Subject: [PATCH] Fix scroll target potentially leaking to other `ScrollArea` --- crates/egui/src/containers/scroll_area.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 448308a04476..c35cca342251 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -756,11 +756,13 @@ impl Prepared { let content_size = content_ui.min_size(); for d in 0..2 { + // We always take both scroll targets regardless of which scroll axes are enabled. This + // is to avoid them leaking to other scroll areas. + let scroll_target = content_ui + .ctx() + .frame_state_mut(|state| state.scroll_target[d].take()); + if scroll_enabled[d] { - // We take the scroll target so only this ScrollArea will use it: - let scroll_target = content_ui - .ctx() - .frame_state_mut(|state| state.scroll_target[d].take()); if let Some((target_range, align)) = scroll_target { let min = content_ui.min_rect().min[d]; let clip_rect = content_ui.clip_rect();