Skip to content

Add Android accessibility collection support to FlatList#57504

Open
krsnaSuraj wants to merge 1 commit into
react:mainfrom
krsnaSuraj:fix/flatlist-accessibility-position
Open

Add Android accessibility collection support to FlatList#57504
krsnaSuraj wants to merge 1 commit into
react:mainfrom
krsnaSuraj:fix/flatlist-accessibility-position

Conversation

@krsnaSuraj

@krsnaSuraj krsnaSuraj commented Jul 10, 2026

Copy link
Copy Markdown

Summary

On Android, FlatList did not expose accessibility collection metadata, so screen readers (TalkBack) could not announce list/grid position for items (issue #30973).

The native stack on main already reads these tags:

  • BaseViewManager#setAccessibilityCollection / #setAccessibilityCollectionItem write R.id.accessibility_collection / R.id.accessibility_collection_item
  • ReactScrollViewAccessibilityDelegate reads them to drive the TalkBack announcements

The only missing piece was the JS propagation, which is what this PR adds. No native changes are required.

Changes (JS only, FlatList.js):

  • Computes accessibilityCollection (itemCount/rowCount/columnCount, incl. multi-column grids) and sets accessibilityRole to list/grid on the underlying VirtualizedList/ScrollView on Android.
  • Attaches accessibilityCollectionItem (correct itemIndex/rowIndex/columnIndex, including numColumns > 1 grids) to each rendered cell.
  • Resets the collection item on the grid row wrapper so the row itself is not counted.
  • Preserves user-provided role, accessibilityRole and accessibilityCollection props.

This directly closes the FlatList-specific issue #30973. It is intentionally scoped to FlatList (a Good first issue) and keeps the change small and low-risk; the broader VirtualizedList/SectionList work is tracked separately in #30977 / #30975.

Changelog:

[Android] [Added] - FlatList now exposes accessibility collection metadata on Android so TalkBack can announce list/grid position

Test Plan

  • Added two Fantom integration tests in FlatList-itest.js:
    • Single-column: asserts accessibilityRole list, itemCount 3, rowCount 3, columnCount 1, and itemIndex 0/1/2 on cells.
    • Multi-column (numColumns={2}): asserts accessibilityRole grid, itemCount 5, rowCount 3, columnCount 2, and correct itemIndex/columnIndex on cells.
  • Verified locally: flow full-check (0 errors), ESLint (0) and Prettier on the touched files.
  • To verify on device: enable TalkBack on Android, navigate a FlatList/numColumns grid - TalkBack should announce position within the list/grid.

Related

Closes #30973
(See also prior attempts #57016, #57008, #54792, #56692 which targeted the broader VirtualizedList layer.)

Copilot AI review requested due to automatic review settings July 10, 2026 05:12
@meta-cla

meta-cla Bot commented Jul 10, 2026

Copy link
Copy Markdown

Hi @krsnaSuraj!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copilot AI left a comment

Copy link
Copy Markdown

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 Android-only propagation of accessibilityCollection (collection-level metadata) and accessibilityCollectionItem (per-item positioning metadata) from FlatList down to the underlying native views so TalkBack can announce item position within a list/grid.

Changes:

  • Compute and pass Android accessibilityCollection + default accessibilityRole (list/grid) from FlatList to VirtualizedList.
  • Attach Android accessibilityCollectionItem to rendered items (including numColumns > 1 grids) while preserving user-provided values.
  • Add Fantom integration coverage for list + multi-column grid accessibility metadata.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
packages/react-native/Libraries/Lists/FlatList.js Adds Android accessibility collection + item metadata propagation for FlatList (list/grid, per-item indices).
packages/react-native/Libraries/Lists/tests/FlatList-itest.js Adds Fantom integration tests asserting Android collection metadata is present for single- and multi-column FlatList.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +717 to +723
const rowAccessibilityProps: any = isAndroid
? {accessibilityCollectionItem: null}
: {};
return (
<View style={StyleSheet.compose(styles.row, columnWrapperStyle)}>
<View
{...rowAccessibilityProps}
style={StyleSheet.compose(styles.row, columnWrapperStyle)}>
Comment on lines 783 to +799
const renderer = strictMode ? this._memoizedRenderer : this._renderer;
const numColumnsValue = numColumnsOrDefault(numColumns);
const androidAccessibilityProps =
Platform.OS === 'android'
? {
accessibilityCollection:
// $FlowFixMe[prop-missing] Internal native prop.
this.props.accessibilityCollection ??
createAccessibilityCollection(this.props.data, numColumnsValue),
accessibilityRole:
this.props.role == null && this.props.accessibilityRole == null
? numColumnsValue > 1
? 'grid'
: 'list'
: this.props.accessibilityRole,
}
: {};
Comment on lines +105 to +108
it('adds Android accessibility collection metadata to list items', () => {
// $FlowFixMe[incompatible-type] Platform.OS is read-only in production.
Platform.OS = 'android';
try {
Comment on lines +141 to +144
it('adds Android accessibility collection metadata to multi-column list items', () => {
// $FlowFixMe[incompatible-type] Platform.OS is read-only in production.
Platform.OS = 'android';
try {
@krsnaSuraj krsnaSuraj force-pushed the fix/flatlist-accessibility-position branch from 6910b94 to c997a4b Compare July 10, 2026 05:44
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Jul 10, 2026
@krsnaSuraj krsnaSuraj force-pushed the fix/flatlist-accessibility-position branch from c997a4b to 6dba326 Compare July 10, 2026 05:47
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Jul 10, 2026
On Android, FlatList did not expose accessibility collection metadata,
so screen readers (TalkBack) could not announce list/grid position.

Changes:
- Computes accessibilityCollection and sets accessibilityRole to list/grid
- Attaches accessibilityCollectionItem to each rendered cell
- Supports horizontal FlatList (numColumns + horizontal)
- Preserves user-provided role/accessibilityRole/accessibilityCollection props

[Android] [Added] - FlatList now exposes accessibility collection metadata

Closes react#30973
@krsnaSuraj krsnaSuraj force-pushed the fix/flatlist-accessibility-position branch from 3d025b3 to 33fd813 Compare July 10, 2026 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Position in Collection not supported by Flatlist

2 participants