Skip to content

fix(a11y): make assetGridItemSemanticIndex 1-based to match previous behavior#754

Merged
AlexV525 merged 1 commit into
fluttercandies:mainfrom
luomo-pro:fix-semantic-index-1-based
Apr 30, 2026
Merged

fix(a11y): make assetGridItemSemanticIndex 1-based to match previous behavior#754
AlexV525 merged 1 commit into
fluttercandies:mainfrom
luomo-pro:fix-semantic-index-1-based

Conversation

@luomo-pro
Copy link
Copy Markdown
Contributor

What

DefaultAssetPickerBuilderDelegate.assetGridItemSemanticIndex currently returns:

return index - prependItems.length;

which produces a 0-based index. As a result, screen readers (VoiceOver / TalkBack) announce assets as "Image 0, Image 1, ..." which is unintuitive and inconsistent with the 1-based indices used by previous versions of this package (e.g. "Image 1, Image 2, ...").

This PR adds + 1 to restore the 1-based announced index.

Why

The 1-based behavior was the long-standing convention in older versions of wechat_assets_picker, where the equivalent function returned index + 1 (no prepend) or index (with prepend). Both branches yielded a 1-based announced index for the first asset.

When this method was refactored to support the new multi-prepend specialItems API, the + 1 offset was inadvertently dropped. The fix restores the original semantics in a single line, with no behavioral change to non-accessibility code paths.

Behavior comparison

With one prepend item present:

Grid index Previous behavior Current main This PR
0 (prepend tile) n/a n/a n/a
1 (1st asset) 1 0 1
2 (2nd asset) 2 1 2

Without prepend items:

Grid index Previous behavior Current main This PR
0 (1st asset) 1 0 1
1 (2nd asset) 2 1 2

Test plan

  • Open a picker (with or without prepend special items).
  • Enable VoiceOver (iOS) or TalkBack (Android).
  • Swipe through the grid and confirm assets are announced as "Image 1, Image 2, ..." rather than "Image 0, Image 1, ...".

Notes

  • Single-line change in lib/src/delegates/asset_picker_builder_delegate.dart.
  • CHANGELOG updated under the Unreleased section.

…behavior

The current implementation returns `index - prependItems.length`, producing
0-based indices announced by screen readers (e.g. "Image 0, Image 1, ...").
This is unintuitive for users and a regression compared with the previous
behavior, which produced 1-based indices ("Image 1, Image 2, ...").

Adding `+ 1` restores the 1-based announced index for assets, regardless of
whether prepend special items exist.
@AlexV525 AlexV525 merged commit f0069c3 into fluttercandies:main Apr 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants