fix(a11y): add List and ListItem accessibility roles & collection met… - #58322
fix(a11y): add List and ListItem accessibility roles & collection met…#58322Ajeethundal wants to merge 2 commits into
Conversation
|
Hi @Ajeethundal! 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! |
4cde7b8 to
c991dc2
Compare
Summary:
Resolves #30973, #30974, #30975, and #30977.
Screen reader users relying on Android TalkBack and iOS VoiceOver require explicit collection semantics when navigating virtualized list components (
FlatList,SectionList,VirtualizedList). Without these, screen readers treat items as isolated, uncounted views instead of announcing:This PR introduces built-in Accessibility Collection Semantics and
list/listitemroles for all virtualized lists in React Native.Key Implementation Highlights:
View Accessibility Interface (
ViewAccessibility.js):'listitem'toAccessibilityRole.AccessibilityCollectionandAccessibilityCollectionItemFlow types.accessibilityCollection,accessibilityCollectionItem,aria-setsize,aria-posinset,aria-rowcount,aria-colcounttoAccessibilityProps.Item-Level Semantics (
VirtualizedListCellRenderer.js):accessibilityRole="listitem",aria-setsize={totalCount},aria-posinset={index + 1}, andaccessibilityCollectionItem(calculating dynamicrowIndexandcolumnIndex).Container-Level Semantics (
VirtualizedList.js):accessibilityRole="list"(or"grid"whennumColumns > 1),aria-rowcount, andaccessibilityCollection.Multi-Column Grid & Edge-Case Protections:
numColumns > 1): Dynamically computes row indices and column indices for multi-columnFlatListgrid layouts.accessibilityCollectionEnabled): AddedaccessibilityCollectionEnabled?: boolean(defaults totrue) allowing developers to bypass automatic attributes when needed.accessibilityRoleoverrides.Changelog:
[GENERAL] [ADDED] - Add Accessibility Collection semantics and list/listitem roles to VirtualizedList, FlatList, and SectionList
Test Plan:
Automated Tests
VirtualizedList-test.js:yarn test packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.jsaccessibilityRole="list",aria-rowcount, itemaccessibilityRole="listitem",aria-setsize,aria-posinset, andaccessibilityCollectionItem.Device & Simulator Verification