From 4714aa7d311fea148e165d293d0800eda518b50e Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 21 Mar 2026 21:52:52 +0100 Subject: [PATCH] Fix instable IDs following animated panels (#7994) * Found thanks to https://github.com/emilk/egui/pull/7984 If you put an animated `Panel` inside a `Ui`, then the automatic ids for following widgets would differ when the panel was collapsed or open. --- crates/egui/src/containers/panel.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/egui/src/containers/panel.rs b/crates/egui/src/containers/panel.rs index f2a4c3b67..4a83ce8d1 100644 --- a/crates/egui/src/containers/panel.rs +++ b/crates/egui/src/containers/panel.rs @@ -561,7 +561,11 @@ impl Panel { let how_expanded = animate_expansion(ui.ctx(), self.id.with("animation"), is_expanded); // Get either the fake or the real panel to animate - let animated_panel = self.get_animated_panel(ui.ctx(), is_expanded)?; + let Some(animated_panel) = self.get_animated_panel(ui.ctx(), is_expanded) else { + // Make sure the ids of the next widgets are the same whether we show the panel or not: + ui.skip_ahead_auto_ids(1); + return None; + }; if how_expanded < 1.0 { // Show a fake panel in this in-between animation state: