Skip to content

Commit

Permalink
[iOS] Fix deselecting an item
Browse files Browse the repository at this point in the history
  • Loading branch information
rmarinho committed Dec 3, 2024
1 parent 6f9464b commit a065db2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ internal void ClearSelection()

foreach (var index in selectedItemIndexes)
{
CollectionView.DeselectItem(index, true);
CollectionView.PerformBatchUpdates(null, _ =>
{
CollectionView.DeselectItem(index, true);
});
}
}

Expand Down Expand Up @@ -158,7 +161,10 @@ void SynchronizePlatformSelectionWithSelectedItems()
var itemAtPath = GetItemAtIndex(path);
if (!selectedItems.Contains(itemAtPath))
{
CollectionView.DeselectItem(path, true);
CollectionView.PerformBatchUpdates(null, _ =>
{
CollectionView.DeselectItem(path, true);
});
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal void SelectItem(object selectedItem)

if (index.Section > -1 && index.Item > -1)
{
// Ensure the selected index is updated after the collection view's items generation is completed
// Ensure the selected index is updated after the collection view's items generation is completed
CollectionView.PerformBatchUpdates(null, _ =>
{
CollectionView.SelectItem(index, true, UICollectionViewScrollPosition.None);
Expand All @@ -55,7 +55,10 @@ internal void ClearSelection()

foreach (var index in selectedItemIndexes)
{
CollectionView.DeselectItem(index, true);
CollectionView.PerformBatchUpdates(null, _ =>
{
CollectionView.DeselectItem(index, true);
});
}
}

Expand Down Expand Up @@ -158,7 +161,10 @@ void SynchronizePlatformSelectionWithSelectedItems()
var itemAtPath = GetItemAtIndex(path);
if (!selectedItems.Contains(itemAtPath))
{
CollectionView.DeselectItem(path, true);
CollectionView.PerformBatchUpdates(null, _ =>
{
CollectionView.DeselectItem(path, true);
});
}
else
{
Expand Down

0 comments on commit a065db2

Please sign in to comment.