-
Notifications
You must be signed in to change notification settings - Fork 2k
[Windows] Fix CarouselView EmptyView display when filtering to zero items #29247
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c2639ef
Fixed the empty view issue
Shalini-Ashokan 7d1e770
Missed to reset a IsLoopingEnabled
Shalini-Ashokan fe505f4
Removed unwanted changes
Shalini-Ashokan aaa5735
Added test cases
Shalini-Ashokan 2bb3dc1
Committed the image
Shalini-Ashokan 1b4151c
Modified the logics
Shalini-Ashokan ebd13ed
Added a mac snapshot
Shalini-Ashokan 1d3133f
Fixed the failures cases
Shalini-Ashokan 786e339
Address a review concern
Shalini-Ashokan 2ebc190
Added base snapshot
Shalini-Ashokan f6b51cb
Merge branch 'inflight/current' into fix-7150
kubaflo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
+27.9 KB
...tests/TestCases.Android.Tests/snapshots/android/VerifyCarouselViewEmptyView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
148 changes: 148 additions & 0 deletions
148
src/Controls/tests/TestCases.HostApp/Issues/Issue7150.cs
This file contains hidden or 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,148 @@ | ||
| using System; | ||
| using System.Collections.ObjectModel; | ||
| using System.Windows.Input; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
| [Issue(IssueTracker.Github, 7150, "EmptyView using Template displayed at the same time as the content", PlatformAffected.UWP)] | ||
| public class Issue7150 : TestContentPage | ||
| { | ||
| public Issue7150() | ||
| { | ||
| Title = "Issue 7150"; | ||
| BindingContext = new Issue7150ViewModel(); | ||
| } | ||
| protected override void Init() | ||
| { | ||
| var filterButton = new Button | ||
| { | ||
| Margin = new Thickness(20), | ||
| AutomationId = "FilterButton", | ||
| Text = "Filter" | ||
| }; | ||
| filterButton.SetBinding(Button.CommandProperty, "FilterCommand"); | ||
|
|
||
| var emptyViewContent = new StackLayout | ||
| { | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Start, | ||
| Children = | ||
| { | ||
| new Label | ||
| { | ||
| Text = "No results matched your filter.", | ||
| Margin = new Thickness(10, 25, 10, 10), | ||
| FontAttributes = FontAttributes.Bold, | ||
| FontSize = 18, | ||
| HorizontalTextAlignment = TextAlignment.Center | ||
| }, | ||
| new Label | ||
| { | ||
| Text = "Try a broader filter?", | ||
| FontAttributes = FontAttributes.Italic, | ||
| FontSize = 12, | ||
| HorizontalTextAlignment = TextAlignment.Center | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| var emptyView = new ContentView { Content = emptyViewContent }; | ||
| var carouselView = new CarouselView | ||
| { | ||
| ItemTemplate = GetCarouselTemplate(), | ||
| EmptyView = emptyView, | ||
| }; | ||
|
|
||
| carouselView.SetBinding(ItemsView.ItemsSourceProperty, "Items"); | ||
| var grid = new Grid | ||
| { | ||
| RowDefinitions = new RowDefinitionCollection | ||
| { | ||
| new RowDefinition { Height = GridLength.Auto }, | ||
| new RowDefinition { Height = GridLength.Star } | ||
| } | ||
| }; | ||
|
|
||
| grid.Add(filterButton, 0, 0); | ||
| grid.Add(carouselView, 0, 1); | ||
| Content = grid; | ||
| } | ||
|
|
||
| internal DataTemplate GetCarouselTemplate() | ||
| { | ||
| return new DataTemplate(() => | ||
| { | ||
| var grid = new Grid(); | ||
| var info = new Label | ||
| { | ||
| HorizontalOptions = LayoutOptions.Center, | ||
| VerticalOptions = LayoutOptions.Center, | ||
| Margin = new Thickness(6) | ||
| }; | ||
|
|
||
| info.SetBinding(Label.TextProperty, new Binding("Name")); | ||
| grid.Children.Add(info); | ||
| return grid; | ||
| }); | ||
| } | ||
|
|
||
| public class Issue7150Model | ||
| { | ||
| public string Name { get; set; } | ||
| } | ||
|
|
||
| public class Issue7150ViewModel : BindableObject | ||
| { | ||
| ObservableCollection<Issue7150Model> _items; | ||
| public ICommand FilterCommand => new Command(FilterItems); | ||
| readonly IList<Issue7150Model> source; | ||
|
|
||
| public Issue7150ViewModel() | ||
| { | ||
| source = new List<Issue7150Model>(); | ||
| source.Add(new Issue7150Model | ||
| { | ||
| Name = "Baboon" | ||
| }); | ||
| source.Add(new Issue7150Model | ||
| { | ||
| Name = "Capuchin Monkey" | ||
| }); | ||
| source.Add(new Issue7150Model | ||
| { | ||
| Name = "Blue Monkey" | ||
| }); | ||
|
|
||
| Items = new ObservableCollection<Issue7150Model>(source); | ||
| } | ||
|
|
||
| public ObservableCollection<Issue7150Model> Items | ||
| { | ||
| get { return _items; } | ||
| set | ||
| { | ||
| _items = value; | ||
| OnPropertyChanged(); | ||
| } | ||
| } | ||
|
|
||
| public void FilterItems() | ||
| { | ||
| var filter = "Mandrill"; | ||
| var filteredItems = source.Where(monkey => monkey.Name?.Contains(filter, StringComparison.OrdinalIgnoreCase) ?? false).ToList(); | ||
| foreach (var monkey in source) | ||
| { | ||
| if (!filteredItems.Contains(monkey)) | ||
| { | ||
| Items?.Remove(monkey); | ||
| } | ||
| else | ||
| { | ||
| if (Items != null && !Items.Contains(monkey)) | ||
| { | ||
| Items.Add(monkey); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
Binary file added
BIN
+12.5 KB
...ontrols/tests/TestCases.Mac.Tests/snapshots/mac/VerifyCarouselViewEmptyView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions
22
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue7150.cs
This file contains hidden or 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,22 @@ | ||
| #if TEST_FAILS_ON_WINDOWS // Related issue for windows: https://github.com/dotnet/maui/issues/29245 | ||
|
kubaflo marked this conversation as resolved.
Shalini-Ashokan marked this conversation as resolved.
|
||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
| public class Issue7150 : _IssuesUITest | ||
| { | ||
| public Issue7150(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "EmptyView using Template displayed at the same time as the content"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CarouselView)] | ||
| public void VerifyCarouselViewEmptyView() | ||
| { | ||
| App.WaitForElement("FilterButton"); | ||
| App.Tap("FilterButton"); | ||
| VerifyScreenshot(); | ||
|
jsuarezruiz marked this conversation as resolved.
|
||
| } | ||
| } | ||
| #endif | ||
Binary file added
BIN
+30 KB
...rols/tests/TestCases.iOS.Tests/snapshots/ios-26/VerifyCarouselViewEmptyView.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
+29.4 KB
...ontrols/tests/TestCases.iOS.Tests/snapshots/ios/VerifyCarouselViewEmptyView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.