Skip to content

Fix Android FlatList accessibility collection positions#57008

Closed
popsiclelmlm wants to merge 1 commit into
facebook:mainfrom
popsiclelmlm:codex/30973-flatlist-a11y-position
Closed

Fix Android FlatList accessibility collection positions#57008
popsiclelmlm wants to merge 1 commit into
facebook:mainfrom
popsiclelmlm:codex/30973-flatlist-a11y-position

Conversation

@popsiclelmlm
Copy link
Copy Markdown

@popsiclelmlm popsiclelmlm commented May 31, 2026

Summary:

Fixes #30973. Related to #30975 and #30977.

On Android, FlatList and VirtualizedList now provide accessibility collection metadata so TalkBack can report collection positions for rendered items. FlatList sets list/grid collection info, attaches collection item data to rendered item roots, and the Android scroll delegate resolves visible item ranges from nested tagged descendants.

Relation to previous attempts

This area has prior history in #33180 and the currently open #56692.

  • TalkBack support for ScrollView accessibility announcements (list and grid) #33180 landed in 2022 and was later reverted because of Meta internal land-safety issues. The current codebase already retains the native Android plumbing for accessibilityCollection and accessibilityCollectionItem, so this PR focuses on wiring list metadata through FlatList/VirtualizedList instead of re-adding the broader native View API surface.
  • Compared with feat: Add accessibility collection support to VirtualizedList #56692, this PR keeps the change narrower and includes the fields expected by the current Android scroll accessibility delegate (itemCount, rowCount, columnCount, and hierarchical).
  • The FlatList path attaches accessibilityCollectionItem to the rendered item root when possible, while preserving an explicit accessibilityCollectionItem supplied by user code. For multi-column FlatList rows, each rendered item gets its own item/column index.
  • The scroll delegate now recursively scans visible descendants for collection item tags. This avoids assuming that the first direct child is the accessible item, which matters for spacers, wrappers, and multi-column rows.
  • The PR preserves explicit user-provided role, accessibilityRole, and accessibilityCollection props.
  • This is implemented without changing the public JS API snapshot; accessibilityCollectionItem stays an internal native prop wiring detail for these list components.

Changelog:

[ANDROID] [FIXED] - Fix FlatList accessibility collection position announcements.

Test Plan:

  • PATH=/Users/liumin/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH ./node_modules/.bin/jest packages/react-native/Libraries/Lists/__tests__/FlatList-test.js --runInBand
  • PATH=/Users/liumin/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH ./node_modules/.bin/jest packages/virtualized-lists/Lists/__tests__/VirtualizedList-test.js --runInBand
  • PATH=/Users/liumin/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH yarn build-types --validate
  • PATH=/Users/liumin/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH YARN_BINARY=/Users/liumin/.cache/node/corepack/v1/yarn/1.22.22/bin/yarn ./gradlew :packages:react-native:ReactAndroid:testDebugUnitTest --tests com.facebook.react.views.scroll.ReactScrollViewAccessibilityDelegateTest -Preact.internal.useHermesStable=true
  • PATH=/Users/liumin/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH YARN_BINARY=/Users/liumin/.cache/node/corepack/v1/yarn/1.22.22/bin/yarn ./gradlew :packages:react-native:ReactAndroid:ktfmtCheck -Preact.internal.useHermesStable=true
  • PATH=/Users/liumin/.cache/codex-runtimes/codex-primary-runtime/dependencies/node/bin:$PATH ./node_modules/.bin/prettier --check packages/react-native/Libraries/Lists/FlatList.js packages/react-native/Libraries/Lists/__tests__/FlatList-test.js packages/virtualized-lists/Lists/VirtualizedList.js packages/virtualized-lists/Lists/VirtualizedListCellRenderer.js packages/virtualized-lists/Lists/VirtualizedListProps.js
  • git diff --check

@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 31, 2026

Hi @popsiclelmlm!

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!

@popsiclelmlm
Copy link
Copy Markdown
Author

Hi @popsiclelmlm!

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!

retry check

@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 May 31, 2026
@meta-cla
Copy link
Copy Markdown

meta-cla Bot commented May 31, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 May 31, 2026
@popsiclelmlm popsiclelmlm force-pushed the codex/30973-flatlist-a11y-position branch from 967cdbf to e9b2647 Compare June 1, 2026 09:52
@popsiclelmlm popsiclelmlm deleted the codex/30973-flatlist-a11y-position branch June 1, 2026 10:02
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

1 participant