feat: Add accessibility collection support to VirtualizedList#56692
feat: Add accessibility collection support to VirtualizedList#56692saisreelasyaappali wants to merge 1 commit into
Conversation
This enables Android TalkBack to announce "item X of Y" when navigating through VirtualizedList/FlatList items. Changes: - Add AccessibilityCollectionItem type to VirtualizedListProps - Compute and pass accessibilityCollectionItem to each cell in VirtualizedList - Apply accessibilityCollectionItem prop on cell wrapper View - Add accessibilityCollection (rowCount/columnCount) to ScrollView - Add Flow types for AccessibilityCollection and AccessibilityCollectionItem - Fix FlatList multi-column grid accessibility with proper row/column indices Closes facebook#30975
|
Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
It looks like a version of this landed a while back in #33180 but broke some internal signals and was never re-landed. Can you compare approaches? |
popsiclelmlm
left a comment
There was a problem hiding this comment.
Leaving a few notes because this overlaps with the same area I investigated in #57016, and @javache asked about comparing approaches with #33180.
A few things look important before this approach can land:
-
The current Android scroll accessibility delegate reads more fields than this PR supplies.
ReactScrollViewAccessibilityDelegatecallsaccessibilityCollection.getInt("itemCount")for the event, and the node-info path readsrowCount,columnCount, andhierarchical. It also expects visible collection items to carry anitemIndexforevent.fromIndex/event.toIndex. This PR currently suppliesrowCount/columnCounton the collection androwIndex/columnIndexon items, but notitemCount,hierarchical, oritemIndex, so scroll accessibility events will not have the data the native code expects. -
VirtualizedListbuilds a generatedaccessibilityCollectionafter spreadingthis.props, so it overwrites a user-providedaccessibilityCollection. We should preserve explicit user props here, similar to howrole/accessibilityRoleshould not be overwritten. -
Multi-column
FlatListstill needs special handling. At theVirtualizedListlayer, a multi-column FlatList is represented as rows, so the generated collection becomesrowCount=<row count>, columnCount=1. PassingaccessibilityCollectionItemintorenderIteminfo does not attach it to the rendered item root unless user code opts into that prop. That means grid items may still be announced as rows rather than individual row/column positions. -
This changes the public JS API surface by adding
accessibilityCollectionItemtoListRenderItemInfo/ View accessibility props. If the goal is only internal list wiring, it may be better to keep this prop internal to the list implementation and avoid the extra API-review path.
#57016 takes a narrower pass at the same issue: it preserves user props, includes the fields expected by the current Android delegate, recursively finds tagged descendants for visible ranges, and keeps accessibilityCollectionItem as an internal wiring detail rather than adding it to the public renderItem contract.
This enables Android TalkBack to announce "item X of Y" when navigating through VirtualizedList/FlatList items.
Changes:
Closes #30975
Summary:
This change improves accessibility for VirtualizedList and FlatList by enabling Android TalkBack to correctly announce item position (e.g., "item X of Y") and grid structure. It introduces support for accessibilityCollection and accessibilityCollectionItem, ensuring proper indexing for both single-column and multi-column lists.
Changelog:
[Android] [Added] - Enable TalkBack to announce item position in VirtualizedList and FlatList
Test Plan: