-
Notifications
You must be signed in to change notification settings - Fork 2k
[iOS] Fix ScrollView does not resize when children are removed from StackLayout at runtime #32267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
508f79b
39563c7
94ac744
0d1db14
675c49e
ce765cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 32221, "[iOS] ScrollView does not resize when children are removed from StackLayout at runtime", PlatformAffected.iOS)] | ||
|
|
||
| public class Issue32221 : ContentPage | ||
| { | ||
| int labelCount = 3; | ||
| StackLayout labelStack; | ||
|
|
||
| public Issue32221() | ||
| { | ||
| // Create the label stack | ||
| labelStack = new StackLayout | ||
| { | ||
| BackgroundColor = Colors.Beige, | ||
| Spacing = 10 | ||
| }; | ||
|
|
||
| // Add initial labels | ||
| for (int i = 1; i <= labelCount; i++) | ||
| { | ||
| labelStack.Children.Add(new Label | ||
| { | ||
| Text = $"Label {i}", | ||
| FontSize = 18, | ||
| Padding = new Thickness(10) | ||
| }); | ||
| } | ||
|
|
||
| // Create ScrollView to hold the label stack | ||
| var scrollView = new ScrollView | ||
| { | ||
| Content = labelStack | ||
| }; | ||
|
|
||
| // Create buttons | ||
| var addButton = new Button | ||
| { | ||
| Text = "Add Label", | ||
| AutomationId = "AddLabelButton" | ||
| }; | ||
| addButton.Clicked += OnAddLabelClicked; | ||
|
|
||
| var removeButton = new Button | ||
| { | ||
| Text = "Remove Label", | ||
| AutomationId = "RemoveLabelButton" | ||
| }; | ||
| removeButton.Clicked += OnRemoveLabelClicked; | ||
|
|
||
| // Create the main layout | ||
| var mainLayout = new VerticalStackLayout | ||
| { | ||
| Padding = 20, | ||
| Children = { scrollView, addButton, removeButton } | ||
| }; | ||
|
|
||
| // Set the page content | ||
| Content = mainLayout; | ||
| } | ||
|
|
||
| void OnAddLabelClicked(object sender, EventArgs e) | ||
| { | ||
| labelCount++; | ||
| labelStack.Children.Add(new Label | ||
| { | ||
| Text = $"Label {labelCount}", | ||
| FontSize = 18, | ||
| Padding = new Thickness(10) | ||
| }); | ||
| } | ||
|
|
||
| void OnRemoveLabelClicked(object sender, EventArgs e) | ||
| { | ||
| if (labelStack.Children.Count > 0) | ||
| { | ||
| labelStack.Children.RemoveAt(labelStack.Children.Count - 1); | ||
| labelCount--; | ||
| } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
| public class Issue32221 : _IssuesUITest | ||
| { | ||
| public Issue32221(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "[iOS] ScrollView does not resize when children are removed from StackLayout at runtime"; | ||
| [Test] | ||
| [Category(UITestCategories.ScrollView)] | ||
| public void VerifyScrollViewHeightWhenRemoveChildAtRuntime() | ||
| { | ||
| App.WaitForElement("AddLabelButton"); | ||
| App.Tap("AddLabelButton"); | ||
| App.Tap("RemoveLabelButton"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -610,7 +610,7 @@ bool IPlatformMeasureInvalidationController.InvalidateMeasure(bool isPropagating | |
| SetNeedsLayout(); | ||
| InvalidateConstraintsCache(); | ||
|
|
||
| return !isPropagating; | ||
| return true; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [major] Layout Measure-Arrange — Returning |
||
| } | ||
|
|
||
| /// <summary> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pending snapshots already available in the latest build.
Could you commit the images?