Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
138797f
fix added
devanathan-vaithiyanathan Jun 23, 2025
397a2e8
Revert "fix added"
devanathan-vaithiyanathan Jun 23, 2025
2f47fee
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jun 25, 2025
f3b39cd
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jun 26, 2025
3d75b12
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jul 1, 2025
31c2088
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jul 16, 2025
9f36a23
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jul 25, 2025
eb9b898
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Jul 29, 2025
42f84d6
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Aug 1, 2025
811bcd9
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Aug 4, 2025
7925e71
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Aug 5, 2025
543d9b7
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Aug 6, 2025
a8afd89
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Aug 8, 2025
028ad7d
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Aug 8, 2025
659818e
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Aug 13, 2025
c6444ab
Merge branch 'dotnet:main' into main
devanathan-vaithiyanathan Aug 18, 2025
ec329d7
fix added
devanathan-vaithiyanathan Aug 18, 2025
15aa2b7
test case added
devanathan-vaithiyanathan Aug 19, 2025
3c0a66f
test case modified
devanathan-vaithiyanathan Aug 19, 2025
ba94142
updated Shared file
devanathan-vaithiyanathan Aug 20, 2025
21140c4
comment udpated
devanathan-vaithiyanathan Aug 21, 2025
355f00e
snapshot added
devanathan-vaithiyanathan Aug 25, 2025
fc467b1
condition added
devanathan-vaithiyanathan Aug 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/Controls/src/Core/SwipeView/SwipeView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,18 @@ protected override void OnBindingContextChanged()
SetInheritedBindingContext(RightItems, BindingContext);
SetInheritedBindingContext(TopItems, BindingContext);
SetInheritedBindingContext(BottomItems, BindingContext);

// In Windows and Android, new cells are created when rebinding, so _isOpen is false.
// In iOS, CollectionView reuses cells, so SwipeView remain open (_isOpen = true).
// When new cells are recreated, the swipe state is reset.
// When cells are reused (iOS), the open state is maintained.
// Fix for iOS: Close SwipeView when BindingContext changes to prevent stale open state
#if IOS || MACCATALYST
if (_isOpen)
Copy link
Copy Markdown
Contributor

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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And Catalyst

Copy link
Copy Markdown
Contributor Author

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.

{
((ISwipeView)this).RequestClose(new SwipeViewCloseRequest(false));
}
#endif
}

static void OnSwipeItemsChanged(BindableObject bindable, object oldValue, object newValue)
Expand Down
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 src/Controls/tests/TestCases.HostApp/Issues/Issue19541.cs
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; }
}

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading