Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ internal void SelectItem(object selectedItem)
CollectionView.PerformBatchUpdates(null, _ =>
{
CollectionView.SelectItem(index, true, UICollectionViewScrollPosition.None);
CollectionView.CellForItem(index)?.UpdateSelectedAccessibility(true);
});
}
}
Expand Down Expand Up @@ -76,8 +75,6 @@ void FormsSelectItem(NSIndexPath indexPath)
ItemsView.SelectedItems.Add(GetItemAtIndex(indexPath));
break;
}

CollectionView.CellForItem(indexPath)?.UpdateSelectedAccessibility(true);
}

void FormsDeselectItem(NSIndexPath indexPath)
Expand All @@ -94,8 +91,6 @@ void FormsDeselectItem(NSIndexPath indexPath)
ItemsView.SelectedItems.Remove(GetItemAtIndex(indexPath));
break;
}

CollectionView.CellForItem(indexPath)?.UpdateSelectedAccessibility(false);
}

internal void UpdatePlatformSelection()
Expand Down Expand Up @@ -135,10 +130,6 @@ internal void UpdateSelectionMode()
{
var mode = ItemsView.SelectionMode;

// We want to make sure we clear the selection trait before we switch modes.
// If we do this after we switch modes, cells that are selected may not show up as selected anymore.
CollectionView.ClearSelectedAccessibilityTraits(CollectionView.GetIndexPathsForSelectedItems());

switch (mode)
{
case SelectionMode.None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ internal void SelectItem(object selectedItem)
CollectionView.PerformBatchUpdates(null, _ =>
{
CollectionView.SelectItem(index, true, UICollectionViewScrollPosition.None);
CollectionView.CellForItem(index)?.UpdateSelectedAccessibility(true);
});
}
}
Expand Down Expand Up @@ -76,8 +75,6 @@ void FormsSelectItem(NSIndexPath indexPath)
ItemsView.SelectedItems.Add(GetItemAtIndex(indexPath));
break;
}

CollectionView.CellForItem(indexPath)?.UpdateSelectedAccessibility(true);
}

void FormsDeselectItem(NSIndexPath indexPath)
Expand All @@ -94,8 +91,6 @@ void FormsDeselectItem(NSIndexPath indexPath)
ItemsView.SelectedItems.Remove(GetItemAtIndex(indexPath));
break;
}

CollectionView.CellForItem(indexPath)?.UpdateSelectedAccessibility(false);
}

internal void UpdatePlatformSelection()
Expand Down Expand Up @@ -135,10 +130,6 @@ internal void UpdateSelectionMode()
{
var mode = ItemsView.SelectionMode;

// We want to make sure we clear the selection trait before we switch modes.
// If we do this after we switch modes, cells that are selected may not show up as selected anymore.
CollectionView.ClearSelectedAccessibilityTraits(CollectionView.GetIndexPathsForSelectedItems());

switch (mode)
{
case SelectionMode.None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,8 @@

namespace Microsoft.Maui.Controls.Platform;

internal static class AccessibilityExtensions
internal static class AcessibilityExtensions
{
internal static void UpdateSelectedAccessibility(this UICollectionViewCell cell, bool selected)
{
// Catalyst and iOS Simulators applies/removes the 'Selected' trait to the cell automatically.
// iOS Devices do not apply the 'Selected' trait automatically to the cell unless VoiceOver is on.
// On iOS, the 'Selected' trait needs to be applied to the first child of the cell for VoiceOver to announce it.
#if IOS
if (cell.ContentView is not null && cell.ContentView.Subviews.Length > 0)
{
var firstChild = cell.ContentView.Subviews[0];

if (selected)
{
firstChild.AccessibilityTraits |= UIAccessibilityTrait.Selected;
}
else
{
firstChild.AccessibilityTraits &= ~UIAccessibilityTrait.Selected;
}
}
#endif
}

internal static void ClearSelectedAccessibilityTraits(this UICollectionView collectionView, Foundation.NSIndexPath[] indices)
{
// Catalyst and iOS Simulators applies/removes the 'Selected' trait to the cell automatically.
// iOS Devices do not apply the 'Selected' trait automatically to the cell unless VoiceOver is on.
// On iOS, the 'Selected' trait needs to be applied to the first child of the cell for VoiceOver to announce it.
#if IOS
foreach (var index in indices)
{
var cell = collectionView.CellForItem(index);
if (cell?.ContentView is not null && cell.ContentView.Subviews.Length > 0)
{
var firstChild = cell.ContentView.Subviews[0];
firstChild.AccessibilityTraits &= ~UIAccessibilityTrait.Selected;
}
}
#endif
}

internal static void UpdateAccessibilityTraits(this UICollectionView collectionView, SelectableItemsView itemsView)
{
foreach (var subview in collectionView.Subviews)
Expand Down
24 changes: 0 additions & 24 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue21375.xaml

This file was deleted.

104 changes: 0 additions & 104 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue21375.xaml.cs

This file was deleted.

24 changes: 0 additions & 24 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue21375_2.xaml

This file was deleted.

70 changes: 0 additions & 70 deletions src/Controls/tests/TestCases.HostApp/Issues/Issue21375_2.xaml.cs

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading