-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fixed the crash occurred on CarouselView2 when deleting last one remaining item with loop as false #31537
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 3 commits
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 System.Collections.ObjectModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 31535, "[iOS] Crash occurred on CarouselView2 when deleting last one remaining item with loop as false", PlatformAffected.iOS)] | ||
| public class Issue31535 : ContentPage | ||
| { | ||
| ObservableCollection<string> _items = new(); | ||
| public ObservableCollection<string> Items | ||
| { | ||
| get => _items; | ||
| set | ||
| { | ||
| _items = value; | ||
| OnPropertyChanged(); | ||
| } | ||
| } | ||
| public Issue31535() | ||
| { | ||
| // Initialize items | ||
| Items = new ObservableCollection<string> | ||
| { | ||
| "Item 1", | ||
| "Item 2", | ||
| }; | ||
|
|
||
| // Create CarouselView | ||
| var carousel = new CarouselView2 | ||
| { | ||
| Loop = false, | ||
| HeightRequest = 200, | ||
| ItemsSource = Items, | ||
| AutomationId = "TestCarouselView", | ||
| ItemTemplate = new DataTemplate(() => | ||
| { | ||
| var border = new Border | ||
| { | ||
| Margin = 10, | ||
| WidthRequest = 200, | ||
| BackgroundColor = Colors.Red | ||
| }; | ||
|
|
||
| var label = new Label(); | ||
| label.SetBinding(Label.TextProperty, "."); | ||
|
|
||
| border.Content = label; | ||
| return border; | ||
| }) | ||
| }; | ||
|
|
||
| // Create Button | ||
| var button = new Button | ||
|
||
| { | ||
| AutomationId = "RemoveLastItemButton", | ||
| Text = "Remove last item" | ||
| }; | ||
|
|
||
| button.Clicked += (s, e) => | ||
| { | ||
| if (Items.Count > 0) | ||
| Items.RemoveAt(Items.Count - 1); | ||
| }; | ||
|
|
||
| Content = new VerticalStackLayout | ||
| { | ||
| Children = | ||
| { | ||
| carousel, | ||
| button | ||
| } | ||
| }; | ||
| BindingContext = this; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue31535 : _IssuesUITest | ||
| { | ||
| public Issue31535(TestDevice device) : base(device) { } | ||
|
|
||
| public override string Issue => "[iOS] Crash occurred on CarouselView2 when deleting last one remaining item with loop as false"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.CarouselView)] | ||
| public void CarouselView2ShouldNotCrashOnRemoveLastItem() | ||
|
||
| { | ||
| App.WaitForElement("RemoveLastItemButton"); | ||
| App.Tap("RemoveLastItemButton"); | ||
| //remove last one remaining item | ||
| App.Tap("RemoveLastItemButton"); | ||
| App.WaitForElement("TestCarouselView"); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.