Skip to content

Conversation

@jwlilly
Copy link
Contributor

@jwlilly jwlilly commented Dec 5, 2025

Fixes regression caused by PR #174374. SliverLists are not scrolling with TalkBack. Update fixes the issue by adding the ScrollView or HorizontalScrollView if the scroll actions are present.

Test code used:

import 'package:flutter/material.dart';

void main() => runApp(const MaterialApp(home: MyApp()));

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: <Widget>[
          const SliverAppBar(
            pinned: true,
            expandedHeight: 100.0,
            title: Text('Pinned Semantic Focus'),
            backgroundColor: Colors.blue,
          ),
          // The List
          SliverList(
            delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
              return ListTile(title: Text('Item $index'), subtitle: const Text('Scroll down then navigate back up'));
            }, childCount: 50),
          ),
        ],
      ),
    );
  }
}
screen_recording_20251204_191230.mp4

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@jwlilly jwlilly requested a review from a team as a code owner December 5, 2025 01:24
@github-actions github-actions bot added platform-android Android applications specifically engine flutter/engine related. See also e: labels. team-android Owned by Android platform team labels Dec 5, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request fixes a regression where SliverList widgets were not scrolling with TalkBack on Android. The change in AccessibilityBridge.java correctly sets the className to ScrollView or HorizontalScrollView for semantic nodes with implicit scrolling, which is a more robust approach. A new test in AccessibilityBridgeTest.java validates this fix for both vertical and horizontal scrolling. The changes are correct and well-tested. I have one minor suggestion to improve the new test code.

testSemanticsUpdate = testSemanticsNode.toUpdate();
testSemanticsUpdate.sendUpdateToBridge(accessibilityBridge);
nodeInfo = accessibilityBridge.createAccessibilityNodeInfo(0);
AccessibilityNodeInfo.CollectionInfo collectionInfo = nodeInfo.getCollectionInfo();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The collectionInfo variable is initialized but never used. It can be removed to improve code clarity.

@devtizi
Copy link

devtizi commented Dec 8, 2025

Thanks for the detailed investigation and for opening the PR.
While waiting for the official patch, I tested several approaches that fully restore proper TalkBack navigation behavior in real apps.
Here are three reliable workarounds that developers can use in the meantime:

1. Force the ScrollView role via Semantics (recommended)

Wrapping the CustomScrollView with a Semantics widget and explicitly marking it as scrollable fixes the problem because TalkBack correctly interprets the parent as a scrollable container:

Semantics(
  container: true,
  explicitChildNodes: true,
  scrollable: true,
  child: CustomScrollView(
    slivers: [
      SliverAppBar(
        pinned: true,
        expandedHeight: 100,
        title: Text('Pinned Semantic Focus'),
      ),
      SliverList(
        delegate: SliverChildBuilderDelegate(
          (context, index) => ListTile(
            title: Text('Item $index'),
          ),
          childCount: 50,
        ),
      ),
    ],
  ),
)

Result:
TalkBack now scrolls the list and moves focus to off-screen items correctly.

2. Use SliverPrototypeExtentList (for predictable item height)

If all items have a known extent, switching from SliverList to SliverPrototypeExtentList improves semantic bounds computation and restores correct accessibility focus movement:

SliverPrototypeExtentList(
  prototypeItem: const ListTile(title: Text('Prototype')),
  delegate: SliverChildBuilderDelegate(
    (context, index) => ListTile(title: Text('Item $index')),
    childCount: 50,
  ),
)

Result:
TalkBack no longer jumps back to the SliverAppBar and recognizes the scroll range properly.

3. Replace the SliverList with a traditional ListView using NestedScrollView

For setups that don’t require advanced Sliver behavior, this structure avoids the issue entirely, since ListView exposes scroll actions more reliably:

NestedScrollView(
  headerSliverBuilder: (context, _) => [
    const SliverAppBar(
      pinned: true,
      expandedHeight: 100,
      title: Text('Pinned Semantic Focus'),
    ),
  ],
  body: ListView.builder(
    itemCount: 50,
    itemBuilder: (context, index) =>
        ListTile(title: Text('Item $index')),
  ),
)

@reidbaker reidbaker requested a review from chunhtai December 9, 2025 16:10
@reidbaker
Copy link
Contributor

Hold on merging until chunhtai reviews.

// the visible viewport of a scrollable, unless the node itself does not
// allow implicit scrolling - then we leave the className as view.View.
result.setScrollable(true);
if (semanticsNode.hasFlag(Flag.HAS_IMPLICIT_SCROLLING)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we no longer check for shouldSetCollectionInfo ? looking at the code it looks like it check for at least 2 children and the ancestor has focus before setting the class. They make sense to me. How does this change fix the issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldSetCollectionInfo checks on line 947. But whether a view has collection info or not shouldn't impact whether it scrollable. Collection Info should only impact whether it should be a semantic list or not.
I adjusted the code to add the ScrollView or HorizontalScrollView className to the nodeInfo based on the on if it has the scroll accessibility actions. With a Sliver list, it wasn't scroll with TalkBack because the ScrollView className wasn't being applied

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for response, though I still not sure why sliver list didn't have the scrollable class before given it should have passed the shouldSetCollectionInfo check, but looking at the code again, the current code structure makes more sense after the change. so I think this is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was my fault with the changes for collectionItemInfo. I changed the logic of shouldSetCollectionInfo to target only ListViews. I'm guessing Sliver lists are slightly different so the scrollable class wasn't being applied because shouldSetCollectionInfo doesn't pass for Sliver lists

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Dec 9, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Dec 9, 2025
Merged via the queue into flutter:master with commit 6a1f5b7 Dec 9, 2025
179 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Dec 9, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 9, 2025
@reidbaker reidbaker added the cp: stable cherry pick this pull request to stable release candidate branch label Dec 9, 2025
@flutteractionsbot
Copy link

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 10, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 10, 2025
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
…r down (flutter#179480)

Fixes regression caused by PR
[flutter#174374](flutter#174374). SliverLists
are not scrolling with TalkBack. Update fixes the issue by adding the
ScrollView or HorizontalScrollView if the scroll actions are present.

Test code used: 

``` dart
import 'package:flutter/material.dart';

void main() => runApp(const MaterialApp(home: MyApp()));

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @OverRide
  Widget build(BuildContext context) {
    return Scaffold(
      body: CustomScrollView(
        slivers: <Widget>[
          const SliverAppBar(
            pinned: true,
            expandedHeight: 100.0,
            title: Text('Pinned Semantic Focus'),
            backgroundColor: Colors.blue,
          ),
          // The List
          SliverList(
            delegate: SliverChildBuilderDelegate((BuildContext context, int index) {
              return ListTile(title: Text('Item $index'), subtitle: const Text('Scroll down then navigate back up'));
            }, childCount: 50),
          ),
        ],
      ),
    );
  }
}

```


https://github.com/user-attachments/assets/a3780f6d-8e22-40b7-83eb-38bc406b8821

- Fixing flutter#179450

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Dec 10, 2025
…10593)

Manual roll requested by [email protected]

flutter/flutter@b2de367...6a1f5b7

2025-12-09 [email protected] Fix - Semantics focus does not move outside viewport when moving up or down (flutter/flutter#179480)
2025-12-09 [email protected] Make sure that a CupertinoActionSheetAction doesn't crash in 0x0 envi… (flutter/flutter#178955)
2025-12-09 [email protected] Make sure that a CupertinoPickerDefaultSelectionOverlay doesn't crash… (flutter/flutter#179351)
2025-12-09 [email protected] Make sure that a CupertinoExpansionTile doesn't crash in 0x0 environment (flutter/flutter#178978)
2025-12-09 [email protected] Roll Packages from 33a9a81 to 338ecd3 (5 revisions) (flutter/flutter#179625)
2025-12-09 [email protected] [skia] Update SkSerialProcs to use new type (flutter/flutter#179347)
2025-12-09 [email protected] Roll Skia from 895fa7417947 to 502ee6f2a0d7 (4 revisions) (flutter/flutter#179617)
2025-12-09 [email protected] Roll Skia from 9f276dfa0bdc to 895fa7417947 (1 revision) (flutter/flutter#179608)
2025-12-09 [email protected] Remove unused optional argument in _followDiagnosticableChain (flutter/flutter#179525)
2025-12-08 [email protected] Roll Dart SDK from 3c07646cdcb9 to 019cb923bf62 (1 revision) (flutter/flutter#179595)
2025-12-08 [email protected] Marks Linux_mokey flutter_engine_group_performance to be flaky (flutter/flutter#179115)
2025-12-08 [email protected] Roll Skia from 00e6fc407968 to 9f276dfa0bdc (3 revisions) (flutter/flutter#179594)
2025-12-08 [email protected] Marks Mac_arm64_mokey run_release_test to be flaky (flutter/flutter#177372)
2025-12-08 [email protected] Roll Skia from b1936c760645 to 00e6fc407968 (5 revisions) (flutter/flutter#179589)
2025-12-08 [email protected] MatrixUtils.forceToPoint - simplify and optimize (flutter/flutter#179546)
2025-12-08 [email protected] Change GenerateFilledArcStrip to use non-overlapping triangles (flutter/flutter#179292)
2025-12-08 [email protected] Android implementation of content sizing (flutter/flutter#176063)
2025-12-08 [email protected] Roll Dart SDK from 75899721aa42 to 3c07646cdcb9 (1 revision) (flutter/flutter#179587)
2025-12-08 [email protected] Redistribute TESTOWNERS for Android team (flutter/flutter#179464)
2025-12-08 [email protected] Make sure that a CupertinoListTile doesn't crash in 0x0 environment (flutter/flutter#179109)
2025-12-08 [email protected] Make sure that a CupertinoFocusHalo doesn't crash in 0x0 environment (flutter/flutter#178773)
2025-12-08 [email protected] Make sure that a CupertinoPopupSurface doesn't crash in 0x0 environment (flutter/flutter#178929)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cp: stable cherry pick this pull request to stable release candidate branch engine flutter/engine related. See also e: labels. platform-android Android applications specifically team-android Owned by Android platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants