-
Notifications
You must be signed in to change notification settings - Fork 2k
[iOS][CV2] Fix Rotating the Simulator causes the text on the collection view to disappear. #32664
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
129c59c
e8ccc7c
75b1f38
a1434ef
609eb1c
1353866
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,74 @@ | ||
| using Microsoft.Maui.Controls; | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 32435, "Rotating the Simulator causes the text on the collection view to disappear", PlatformAffected.iOS)] | ||
|
|
||
| public class Issue32435 : ContentPage | ||
| { | ||
| readonly ObservableCollection<string> items = new(); | ||
| readonly CollectionView2 collectionView; | ||
|
|
||
| public Issue32435() | ||
| { | ||
| var rootGrid = new Grid | ||
| { | ||
| Margin = 20, | ||
| RowDefinitions = | ||
| { | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| new RowDefinition { Height = GridLength.Star } | ||
| } | ||
| }; | ||
|
|
||
| var topStack = new StackLayout(); | ||
| topStack.Add(new Label { Text = "CollectionView text should appear after rotating the device", AutomationId = "InstructionLabel" }); | ||
| rootGrid.Add(topStack); | ||
| Grid.SetRow(topStack, 0); | ||
|
|
||
| var addButton = new Button | ||
| { | ||
| Text = "Add", | ||
| AutomationId = "AddButton", | ||
| HorizontalOptions = LayoutOptions.Start, | ||
| VerticalOptions = LayoutOptions.Start | ||
| }; | ||
| addButton.Clicked += ButtonAdd_Clicked; | ||
| rootGrid.Add(addButton); | ||
| Grid.SetRow(addButton, 1); | ||
|
|
||
| var innerGrid = new Grid | ||
| { | ||
| RowDefinitions = | ||
| { | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| new RowDefinition { Height = GridLength.Star } | ||
| } | ||
| }; | ||
|
|
||
| collectionView = new CollectionView2 | ||
| { | ||
| BackgroundColor = Colors.LightSalmon, | ||
| HeightRequest = 50, | ||
| ItemsLayout = new GridItemsLayout(ItemsLayoutOrientation.Horizontal) | ||
| }; | ||
|
|
||
| innerGrid.Add(collectionView); | ||
| Grid.SetRow(collectionView, 0); | ||
|
|
||
| rootGrid.Add(innerGrid); | ||
| Grid.SetRow(innerGrid, 2); | ||
|
|
||
| items.Add("item: " + items.Count); | ||
| collectionView.ItemsSource = items; | ||
|
|
||
| Content = rootGrid; | ||
| } | ||
|
|
||
| void ButtonAdd_Clicked(object sender, System.EventArgs e) | ||
| { | ||
| items.Add("item: " + items.Count); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #if TEST_FAILS_ON_CATALYST && TEST_FAILS_ON_WINDOWS //Issue reproduce only when rotating device. | ||
|
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] Regression Prevention — This conditional includes the test on Android as well as iOS, but the production fix is only in
devanathan-vaithiyanathan marked this conversation as resolved.
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. [moderate] Regression Prevention — This guard also compiles the test into Android because the Android test project defines both |
||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue32435 : _IssuesUITest | ||
| { | ||
| public Issue32435(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "Rotating the Simulator causes the text on the collection view to disappear"; | ||
| [Test] | ||
| [Category(UITestCategories.CollectionView)] | ||
| public void VerifyCollectionViewTextShouldAppearAfterRotatingTheDevice() | ||
| { | ||
| App.WaitForElement("InstructionLabel"); | ||
| App.Tap("AddButton"); | ||
| App.SetOrientationLandscape(); | ||
| App.SetOrientationPortrait(); | ||
| VerifyScreenshot(); | ||
|
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. [high] Regression test is missing the baseline used by the iOS gate The supplied iOS gate failed on this line because
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. [moderate] Regression test may capture before post-rotation layout settles
Please re-wait for a stable element or use a screenshot retry timeout after returning to portrait, for example
devanathan-vaithiyanathan marked this conversation as resolved.
devanathan-vaithiyanathan marked this conversation as resolved.
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. [moderate] Regression Prevention — The screenshot is captured immediately after two orientation changes. |
||
| } | ||
| } | ||
| #endif | ||
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.
[major] CollectionView iOS/MacCatalyst — Returning
trueinvalidates the compositional layout, but it leavesCollectionViewHandler2’sMeasureFirstItemcache intact.TemplatedCell2reuses that cached first-item size after a bounds change, so rotations or split-view resizes can still lay out cells with the pre-rotation measurement for the defaultMeasureFirstItemstrategy. Please clear the cached first-item size when the bounds size changes before invalidating the layout.