Skip to content

Commit 9366c23

Browse files
Revert "Add Accessibility Selected for iOS CollectionView (#29014)" (#29854)
This reverts commit 8a8cef3. Co-authored-by: Shane Neuville <[email protected]>
1 parent 95e49a2 commit 9366c23

24 files changed

+1
-385
lines changed

src/Controls/src/Core/Handlers/Items/iOS/SelectableItemsViewController.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ internal void SelectItem(object selectedItem)
4545
CollectionView.PerformBatchUpdates(null, _ =>
4646
{
4747
CollectionView.SelectItem(index, true, UICollectionViewScrollPosition.None);
48-
CollectionView.CellForItem(index)?.UpdateSelectedAccessibility(true);
4948
});
5049
}
5150
}
@@ -76,8 +75,6 @@ void FormsSelectItem(NSIndexPath indexPath)
7675
ItemsView.SelectedItems.Add(GetItemAtIndex(indexPath));
7776
break;
7877
}
79-
80-
CollectionView.CellForItem(indexPath)?.UpdateSelectedAccessibility(true);
8178
}
8279

8380
void FormsDeselectItem(NSIndexPath indexPath)
@@ -94,8 +91,6 @@ void FormsDeselectItem(NSIndexPath indexPath)
9491
ItemsView.SelectedItems.Remove(GetItemAtIndex(indexPath));
9592
break;
9693
}
97-
98-
CollectionView.CellForItem(indexPath)?.UpdateSelectedAccessibility(false);
9994
}
10095

10196
internal void UpdatePlatformSelection()
@@ -135,10 +130,6 @@ internal void UpdateSelectionMode()
135130
{
136131
var mode = ItemsView.SelectionMode;
137132

138-
// We want to make sure we clear the selection trait before we switch modes.
139-
// If we do this after we switch modes, cells that are selected may not show up as selected anymore.
140-
CollectionView.ClearSelectedAccessibilityTraits(CollectionView.GetIndexPathsForSelectedItems());
141-
142133
switch (mode)
143134
{
144135
case SelectionMode.None:

src/Controls/src/Core/Handlers/Items2/iOS/SelectableItemsViewController2.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ internal void SelectItem(object selectedItem)
4545
CollectionView.PerformBatchUpdates(null, _ =>
4646
{
4747
CollectionView.SelectItem(index, true, UICollectionViewScrollPosition.None);
48-
CollectionView.CellForItem(index)?.UpdateSelectedAccessibility(true);
4948
});
5049
}
5150
}
@@ -76,8 +75,6 @@ void FormsSelectItem(NSIndexPath indexPath)
7675
ItemsView.SelectedItems.Add(GetItemAtIndex(indexPath));
7776
break;
7877
}
79-
80-
CollectionView.CellForItem(indexPath)?.UpdateSelectedAccessibility(true);
8178
}
8279

8380
void FormsDeselectItem(NSIndexPath indexPath)
@@ -94,8 +91,6 @@ void FormsDeselectItem(NSIndexPath indexPath)
9491
ItemsView.SelectedItems.Remove(GetItemAtIndex(indexPath));
9592
break;
9693
}
97-
98-
CollectionView.CellForItem(indexPath)?.UpdateSelectedAccessibility(false);
9994
}
10095

10196
internal void UpdatePlatformSelection()
@@ -135,10 +130,6 @@ internal void UpdateSelectionMode()
135130
{
136131
var mode = ItemsView.SelectionMode;
137132

138-
// We want to make sure we clear the selection trait before we switch modes.
139-
// If we do this after we switch modes, cells that are selected may not show up as selected anymore.
140-
CollectionView.ClearSelectedAccessibilityTraits(CollectionView.GetIndexPathsForSelectedItems());
141-
142133
switch (mode)
143134
{
144135
case SelectionMode.None:

src/Controls/src/Core/Platform/iOS/Extensions/AcessibilityExtensions.cs

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,8 @@
22

33
namespace Microsoft.Maui.Controls.Platform;
44

5-
internal static class AccessibilityExtensions
5+
internal static class AcessibilityExtensions
66
{
7-
internal static void UpdateSelectedAccessibility(this UICollectionViewCell cell, bool selected)
8-
{
9-
// Catalyst and iOS Simulators applies/removes the 'Selected' trait to the cell automatically.
10-
// iOS Devices do not apply the 'Selected' trait automatically to the cell unless VoiceOver is on.
11-
// On iOS, the 'Selected' trait needs to be applied to the first child of the cell for VoiceOver to announce it.
12-
#if IOS
13-
if (cell.ContentView is not null && cell.ContentView.Subviews.Length > 0)
14-
{
15-
var firstChild = cell.ContentView.Subviews[0];
16-
17-
if (selected)
18-
{
19-
firstChild.AccessibilityTraits |= UIAccessibilityTrait.Selected;
20-
}
21-
else
22-
{
23-
firstChild.AccessibilityTraits &= ~UIAccessibilityTrait.Selected;
24-
}
25-
}
26-
#endif
27-
}
28-
29-
internal static void ClearSelectedAccessibilityTraits(this UICollectionView collectionView, Foundation.NSIndexPath[] indices)
30-
{
31-
// Catalyst and iOS Simulators applies/removes the 'Selected' trait to the cell automatically.
32-
// iOS Devices do not apply the 'Selected' trait automatically to the cell unless VoiceOver is on.
33-
// On iOS, the 'Selected' trait needs to be applied to the first child of the cell for VoiceOver to announce it.
34-
#if IOS
35-
foreach (var index in indices)
36-
{
37-
var cell = collectionView.CellForItem(index);
38-
if (cell?.ContentView is not null && cell.ContentView.Subviews.Length > 0)
39-
{
40-
var firstChild = cell.ContentView.Subviews[0];
41-
firstChild.AccessibilityTraits &= ~UIAccessibilityTrait.Selected;
42-
}
43-
}
44-
#endif
45-
}
46-
477
internal static void UpdateAccessibilityTraits(this UICollectionView collectionView, SelectableItemsView itemsView)
488
{
499
foreach (var subview in collectionView.Subviews)

src/Controls/tests/TestCases.HostApp/Issues/Issue21375.xaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/Controls/tests/TestCases.HostApp/Issues/Issue21375.xaml.cs

Lines changed: 0 additions & 104 deletions
This file was deleted.

src/Controls/tests/TestCases.HostApp/Issues/Issue21375_2.xaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/Controls/tests/TestCases.HostApp/Issues/Issue21375_2.xaml.cs

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)