From 5266d00796ca8e3fae6fdf7faa344fc6461c0a78 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Tue, 23 May 2023 11:18:10 +0200 Subject: [PATCH] Fixed removing and later adding children to a scrolling panel showing the scroll bar erroneously --- CHANGELOG.md | 1 + MLEM.Ui/Elements/Panel.cs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff2d522..ff0b43e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Fixes - Fixed Paragraph and Checkbox not reacting to SquishingGroup sizing properly - Fixed TextInput and Slider still reacting to input when they are selected, but not part of the active root - Fixed dropdown menu panels not updating their width when the dropdown's width changes +- Fixed removing and later adding children to a scrolling panel showing the scroll bar erroneously ### MLEM.Data Improvements diff --git a/MLEM.Ui/Elements/Panel.cs b/MLEM.Ui/Elements/Panel.cs index 5f3c58d..6a22775 100644 --- a/MLEM.Ui/Elements/Panel.cs +++ b/MLEM.Ui/Elements/Panel.cs @@ -133,6 +133,10 @@ namespace MLEM.Ui.Elements { if (element == this.ScrollBar) throw new NotSupportedException("A panel that scrolls overflow cannot have its scroll bar removed from its list of children"); base.RemoveChild(element); + + // when removing children, our scroll bar might have to be hidden + // if we don't do this before adding children again, they might incorrectly assume that the scroll bar will still be visible and adjust their size accordingly + this.ScrollSetup(); } ///