Skip to content

Add Accessibility Selected for iOS CollectionView #29014

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
merged 16 commits into from
May 7, 2025

Conversation

tj-devel709
Copy link
Member

@tj-devel709 tj-devel709 commented Apr 15, 2025

Description of Change

When an item is selected in a CollectionView, a screen reader user would expect that the selected item(s) would be announced as "selected". This PR adds the ability to update the accessibility state of the selected item(s) in the CollectionView for both Android and iOS platforms. MacCatalyst and Windows already behave this way.

Edit: Holding off on Android for now

Issues Fixed

Fixes #21375
and partially fixes (but does not close) #27460

@tj-devel709 tj-devel709 added platform/android platform/ios area-controls-collectionview CollectionView, CarouselView, IndicatorView t/a11y Relates to accessibility collectionview-cv2 labels Apr 15, 2025
@tj-devel709 tj-devel709 force-pushed the dev/TJ/AccessibilitySelected branch from 8141c5c to 9686f7e Compare April 16, 2025 15:28
@tj-devel709 tj-devel709 marked this pull request as ready for review April 24, 2025 21:01
@Copilot Copilot AI review requested due to automatic review settings April 24, 2025 21:01
@tj-devel709 tj-devel709 requested a review from a team as a code owner April 24, 2025 21:01
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds accessibility support for CollectionView selection on Android and iOS by updating the accessibility state of selected items so that screen readers announce selection.

  • Added new tests in both TestCases.Shared.Tests and TestCases.HostApp to verify accessibility updates.
  • Introduced new extension methods on iOS to update and clear accessibility traits, and updated the platform-specific handlers accordingly.
  • Updated Android view holder to reflect selection state.

Reviewed Changes

Copilot reviewed 26 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
TestCases.Shared.Tests/Tests/Issues/Issue21375_2.cs Added UI automation tests for double selection scenarios.
TestCases.Shared.Tests/Tests/Issues/Issue21375.cs Provided tests for single and multiple selection modes.
TestCases.HostApp/Issues/Issue21375_2.xaml.cs Updated host app page to support CollectionView selection modes.
TestCases.HostApp/Issues/Issue21375.xaml.cs Updated host app page for CollectionView selection and screenshot verification.
Core/Platform/iOS/Extensions/AcessibilityExtensions.cs Added extension methods to update and clear accessibility traits on iOS.
Core/Handlers/Items2/iOS/SelectableItemsViewController2.cs Injected calls to update accessibility traits on item selection changes.
Core/Handlers/Items/iOS/SelectableItemsViewController.cs Similar updates as in Items2, updating accessibility traits on selection/deselection.
Core/Handlers/Items/Android/SelectableViewHolder.cs Updated the Android view holder to reflect selection state changes.
Files not reviewed (2)
  • src/Controls/tests/TestCases.HostApp/Issues/Issue21375.xaml: Language not supported
  • src/Controls/tests/TestCases.HostApp/Issues/Issue21375_2.xaml: Language not supported
Comments suppressed due to low confidence (1)

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

  • The class name 'AcessibilityExtensions' appears to be misspelled; consider renaming it to 'AccessibilityExtensions' for clarity and consistency.
internal static class AcessibilityExtensions

@PureWeen PureWeen moved this from Todo to Ready To Review in MAUI SDK Ongoing Apr 30, 2025
@PureWeen PureWeen changed the title Add Accessibility Selected for Android and iOS CollectionView Add Accessibility Selected for iOS CollectionView May 7, 2025
@github-project-automation github-project-automation bot moved this from Ready To Review to Approved in MAUI SDK Ongoing May 7, 2025
@PureWeen PureWeen merged commit 8a8cef3 into main May 7, 2025
128 checks passed
@PureWeen PureWeen deleted the dev/TJ/AccessibilitySelected branch May 7, 2025 15:23
@github-project-automation github-project-automation bot moved this from Approved to Done in MAUI SDK Ongoing May 7, 2025
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request May 9, 2025
* work for iOS and Android

* sample code to remove later

* working when changing selectionMode with iOS and android

* UITests

* Adds windows to UITest

* add tests for CV2

* screenshots 1

* screenshots 2

* screenshots 3

* screenshots 4

* add windows delay and rename similarly named tests

* screenshots 5

* screenshots 6

* screenshots 7

* typo in class name

* removing android stuff
PureWeen added a commit that referenced this pull request Jun 4, 2025
PureWeen added a commit that referenced this pull request Jun 6, 2025
github-actions bot pushed a commit that referenced this pull request Jun 6, 2025
rmarinho pushed a commit that referenced this pull request Jun 6, 2025
…29854)

This reverts commit 8a8cef3.

Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
rmarinho pushed a commit that referenced this pull request Jun 6, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Jun 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-collectionview CollectionView, CarouselView, IndicatorView collectionview-cv2 platform/android platform/ios t/a11y Relates to accessibility
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Android TalkBack screen reader doesn't tell the user which item is selected in a .NET MAUI CollectionView
2 participants