-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[iOS] Fix SwipeView stays open on iOS after updating content #31248
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
kubaflo
merged 23 commits into
dotnet:inflight/current
from
devanathan-vaithiyanathan:fix-19541
Feb 23, 2026
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
138797f
fix added
devanathan-vaithiyanathan 397a2e8
Revert "fix added"
devanathan-vaithiyanathan 2f47fee
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan f3b39cd
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan 3d75b12
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan 31c2088
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan 9f36a23
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan eb9b898
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan 42f84d6
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan 811bcd9
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan 7925e71
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan 543d9b7
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan a8afd89
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan 028ad7d
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan 659818e
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan c6444ab
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan ec329d7
fix added
devanathan-vaithiyanathan 15aa2b7
test case added
devanathan-vaithiyanathan 3c0a66f
test case modified
devanathan-vaithiyanathan ba94142
updated Shared file
devanathan-vaithiyanathan 21140c4
comment udpated
devanathan-vaithiyanathan 355f00e
snapshot added
devanathan-vaithiyanathan fc467b1
condition added
devanathan-vaithiyanathan 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
Binary file added
BIN
+27.4 KB
...d.Tests/snapshots/android/SwipeItemShouldBeCloseWhenUpdateTheCollectionView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
127 changes: 127 additions & 0 deletions
127
src/Controls/tests/TestCases.HostApp/Issues/Issue19541.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,127 @@ | ||
| using System.Collections.ObjectModel; | ||
|
|
||
| namespace Maui.Controls.Sample.Issues; | ||
|
|
||
| [Issue(IssueTracker.Github, 19541, "[iOS] - Swipeview with collectionview issue", PlatformAffected.iOS)] | ||
|
|
||
| public class Issue19541 : ContentPage | ||
| { | ||
| SwipeView _swipeView; | ||
| CollectionView collectionView; | ||
|
|
||
| public Issue19541() | ||
| { | ||
| // Root layout | ||
| var rootLayout = new VerticalStackLayout(); | ||
|
|
||
| // Refresh button | ||
| var refreshButton = new Button | ||
| { | ||
| Text = "Refresh List", | ||
| AutomationId = "RefreshButton", | ||
| Margin = new Thickness(10) | ||
| }; | ||
| refreshButton.Clicked += OnRefreshClicked; | ||
|
|
||
| // Open button | ||
| var openButton = new Button | ||
| { | ||
| Text = "Open", | ||
| AutomationId = "OpenButton" | ||
| }; | ||
| openButton.Clicked += Button_Clicked; | ||
|
|
||
| // CollectionView | ||
| collectionView = new CollectionView(); | ||
|
|
||
| // Define ItemTemplate in code | ||
| collectionView.ItemTemplate = new DataTemplate(() => | ||
| { | ||
| var swipeView = new SwipeView | ||
| { | ||
| HeightRequest = 60 | ||
| }; | ||
|
|
||
| swipeView.Loaded += swipeView_Loaded; | ||
|
|
||
| var label = new Label(); | ||
| label.SetBinding(Label.TextProperty, "Name"); | ||
|
|
||
| // Swipe RightItems | ||
| var swipeItems = new SwipeItems | ||
| { | ||
| SwipeBehaviorOnInvoked = SwipeBehaviorOnInvoked.Close | ||
| }; | ||
|
|
||
| var swipeItemView = new SwipeItemView | ||
| { | ||
| Content = new Button | ||
| { | ||
| BackgroundColor = Colors.Pink, | ||
| Text = "Delete" | ||
| } | ||
| }; | ||
|
|
||
| swipeItems.Add(swipeItemView); | ||
| swipeView.RightItems = swipeItems; | ||
|
|
||
| swipeView.Content = label; | ||
|
|
||
| return swipeView; | ||
| }); | ||
|
|
||
| // Add controls to layout | ||
| rootLayout.Children.Add(refreshButton); | ||
| rootLayout.Children.Add(openButton); | ||
| rootLayout.Children.Add(collectionView); | ||
|
|
||
| Content = rootLayout; | ||
|
|
||
| LoadInitialList(); | ||
| } | ||
|
|
||
| void LoadInitialList() | ||
| { | ||
| var list = new List<Issue19541Model>(); | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| list.Add(new Issue19541Model | ||
| { | ||
| Name = $"Name {i}", | ||
| }); | ||
| } | ||
|
|
||
| collectionView.ItemsSource = list; | ||
| } | ||
|
|
||
| void OnRefreshClicked(object sender, EventArgs e) | ||
| { | ||
| var list = new List<Issue19541Model>(); | ||
| for (int i = 0; i < 3; i++) | ||
| { | ||
| list.Add(new Issue19541Model | ||
| { | ||
| Name = $"Name {i}", | ||
| }); | ||
| } | ||
|
|
||
| collectionView.ItemsSource = list; | ||
| } | ||
|
|
||
| void swipeView_Loaded(object sender, EventArgs e) | ||
| { | ||
| if (_swipeView is null) | ||
| _swipeView = (SwipeView)sender; | ||
| } | ||
|
|
||
| void Button_Clicked(object sender, EventArgs e) | ||
| { | ||
| _swipeView?.Open(OpenSwipeItem.RightItems); | ||
| } | ||
| } | ||
|
|
||
| public class Issue19541Model | ||
| { | ||
| public string Name { get; set; } | ||
| } | ||
|
|
Binary file added
BIN
+9.65 KB
...s.Mac.Tests/snapshots/mac/SwipeItemShouldBeCloseWhenUpdateTheCollectionView.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions
26
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue19541.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,26 @@ | ||
| #if TEST_FAILS_ON_WINDOWS //More info: https://github.com/dotnet/maui/issues/14777 | ||
| using NUnit.Framework; | ||
| using UITest.Appium; | ||
| using UITest.Core; | ||
|
|
||
| namespace Microsoft.Maui.TestCases.Tests.Issues; | ||
|
|
||
| public class Issue19541 : _IssuesUITest | ||
| { | ||
| public Issue19541(TestDevice device) : base(device) | ||
| { | ||
| } | ||
|
|
||
| public override string Issue => "[iOS] - Swipeview with collectionview issue"; | ||
|
|
||
| [Test] | ||
| [Category(UITestCategories.SwipeView)] | ||
| public void SwipeItemShouldBeCloseWhenUpdateTheCollectionView() | ||
| { | ||
| App.WaitForElement("RefreshButton"); | ||
| App.Tap("OpenButton"); | ||
| App.Tap("RefreshButton"); | ||
| VerifyScreenshot(); | ||
| } | ||
| } | ||
| #endif |
Binary file added
BIN
+27.9 KB
...s.iOS.Tests/snapshots/ios/SwipeItemShouldBeCloseWhenUpdateTheCollectionView.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.
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.
Should use a compilation directive and only do this on iOS?
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.
And Catalyst
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.
@jsuarezruiz , Based on suggestion, I have modified the changes.