forked from dotnet/maui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for CollectionView SelectedItem loses Background after opening an…
…d closing a Modal page (dotnet#26694) * Fixed-22467 : CollectionView SelectedItem loses Background after opening and closing a Modal page * UI test images updated * UI test images updated * ios UI test image updated --------- Co-authored-by: praveenkumarkarunanithi <[email protected]> Co-authored-by: praveenkumarkarunanithi <[email protected]>
- Loading branch information
1 parent
e3a4c07
commit 758b5e3
Showing
9 changed files
with
134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+21.1 KB
...droid/CollectionViewSelectedItemBackgroundShouldPersistAfterModalNavigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions
58
src/Controls/tests/TestCases.HostApp/Issues/Issue22467.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage | ||
xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Maui.Controls.Sample.Issues.Issue22467" | ||
xmlns:local="clr-namespace:Maui.Controls.Sample.Issues"> | ||
<Grid> | ||
|
||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto"/> | ||
<RowDefinition Height="Auto"/> | ||
</Grid.RowDefinitions> | ||
|
||
<CollectionView x:Name="ResultCollectionView" | ||
AutomationId="CollectionView" | ||
Grid.Row="0" | ||
MinimumHeightRequest="150" | ||
MaximumHeightRequest="300" | ||
SelectionMode="Single"> | ||
|
||
<CollectionView.ItemTemplate> | ||
<DataTemplate> | ||
<VerticalStackLayout> | ||
|
||
<VisualStateManager.VisualStateGroups> | ||
<VisualStateGroup Name="CommonStates"> | ||
<VisualState Name="Normal"/> | ||
<VisualState Name="Selected"> | ||
<VisualState.Setters> | ||
<Setter Property="BackgroundColor" | ||
Value="LightGreen"/> | ||
</VisualState.Setters> | ||
</VisualState> | ||
</VisualStateGroup> | ||
</VisualStateManager.VisualStateGroups> | ||
|
||
<Label Text="{Binding}" | ||
FontSize="14" | ||
VerticalTextAlignment="Center" | ||
Margin="25,7,7,7"/> | ||
|
||
<BoxView HeightRequest="1" | ||
BackgroundColor="Black"/> | ||
|
||
</VerticalStackLayout> | ||
</DataTemplate> | ||
</CollectionView.ItemTemplate> | ||
</CollectionView> | ||
|
||
<Button Grid.Row="1" | ||
x:Name="CounterBtn" | ||
AutomationId="PushModalAsyncButton" | ||
Text="Push New Page" | ||
SemanticProperties.Hint="Counts the number of times you click" | ||
Clicked="CounterBtn_Clicked" | ||
HorizontalOptions="Fill"/> | ||
</Grid> | ||
</ContentPage> |
45 changes: 45 additions & 0 deletions
45
src/Controls/tests/TestCases.HostApp/Issues/Issue22467.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
namespace Maui.Controls.Sample.Issues | ||
{ | ||
[XamlCompilation(XamlCompilationOptions.Compile)] | ||
[Issue(IssueTracker.Github, 22467, "CollectionView SelectedItem Background Reset After Modal Navigation", PlatformAffected.iOS)] | ||
public partial class Issue22467 : ContentPage | ||
{ | ||
public Issue22467() | ||
{ | ||
InitializeComponent(); | ||
List<string> list = new() { "1", "2", "3", "4", "5" }; | ||
ResultCollectionView.ItemsSource = list; | ||
ResultCollectionView.SelectedItem = list[3]; | ||
} | ||
|
||
private async void CounterBtn_Clicked(object sender, EventArgs e) | ||
{ | ||
await Navigation.PushModalAsync(CreateNewPage1()); | ||
} | ||
|
||
private ContentPage CreateNewPage1() | ||
{ | ||
var newPage = new ContentPage | ||
{ | ||
Title = "NewPage1", | ||
Content = new VerticalStackLayout | ||
{ | ||
Children = | ||
{ | ||
new Button | ||
{ | ||
Text = "Pop to Main Page", | ||
AutomationId = "PopModalAsyncButton", | ||
Command = new Command(async () => | ||
{ | ||
await Navigation.PopModalAsync(true); | ||
}) | ||
} | ||
} | ||
} | ||
}; | ||
|
||
return newPage; | ||
} | ||
} | ||
} |
Binary file added
BIN
+45.6 KB
...s/mac/CollectionViewSelectedItemBackgroundShouldPersistAfterModalNavigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue22467.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using NUnit.Framework; | ||
using UITest.Appium; | ||
using UITest.Core; | ||
|
||
namespace Microsoft.Maui.TestCases.Tests.Issues | ||
{ | ||
internal class Issue22467 : _IssuesUITest | ||
{ | ||
public Issue22467(TestDevice device) : base(device) { } | ||
|
||
public override string Issue => "CollectionView SelectedItem Background Reset After Modal Navigation"; | ||
|
||
[Test] | ||
[Category(UITestCategories.CollectionView)] | ||
public void CollectionViewSelectedItemBackgroundShouldPersistAfterModalNavigation() | ||
{ | ||
App.WaitForElement("CollectionView"); | ||
App.Tap("PushModalAsyncButton"); | ||
App.WaitForElement("PopModalAsyncButton"); | ||
App.Tap("PopModalAsyncButton"); | ||
App.WaitForElement("CollectionView"); | ||
VerifyScreenshot(); | ||
} | ||
} | ||
} |
Binary file added
BIN
+6.75 KB
...ndows/CollectionViewSelectedItemBackgroundShouldPersistAfterModalNavigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+21.3 KB
...s/ios/CollectionViewSelectedItemBackgroundShouldPersistAfterModalNavigation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.