You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Scrollviews need to announce which items of how many are shown #10595
This uses the getFromIndex and getToIndex of an accessibility record to produce the event. There is also some logic to determine the name of the page.
In theory this could be supported for any List, but I'm not sure yet how it considers items that are outside of the viewport. Since we prune lists, if we wanted to handle the offscreen count we would need to provide the total number of children and current start index.
The only change that needs to made on the engine side is trivial - add two more members describing the total number of children and the index of the first node in the child array, then Talkback handles the rest:
The difficulty I've had is how exactly to get this information onto a single semantics node. Currently the scroll events are dispatched from the node created by Scrollable - but this only knows about the viewport and has no concept of children. Really what I would like so for a child that knows the child count, like the SliverList to tell this scrollable the child information. Haven't found a way to do this yet.
So I've spent some time on this and figured out there may just be too many issues blocking a fully general automagic solution for CustomScrollView:
We don't know how many slivers can be rendered
We don't know which ones will actually contribute semantics
We don't know where one RenderSliverMuli* ends and another ends.
Indexes may not start at 0, or even increase.
Even though all of the bits are there, they are spread out and not always available at the right time. I've prototyped some solutions that work by encoding the values into the semantics tree, but it quickly becomes very cumbersome - i.e. traversing 2 or 3 levels of semantics nodes to collect information. I don't feel confident that this is actually a generally solution.
As an alternative we could not fix it, but I think this degrades the accessibility experience for fairly common cases like ListViews. My solution is fairly simple, but requires developer specific for more complex cases.
CustomScrollView takes an 'int scroll(semantics)Children' parameter which declares the total number of scroll children which contribute semantics. This can be supplied by default for ListView.
For indexes we require the user to wrap children in a SemanticsIndex(child: child, index: index). This can be done automatically for ListView. This does run the risk of marking dividers as important for semantics, but I still think this is better than the alternative.
We can still try and work on a better API, or perhaps find more cases where we can automatically infer indexes in the mean time.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
jonahwilliams commentedon Jul 19, 2018
on Android, the announcement is produced from the following method in talkback: https://github.com/google/talkback/blob/e69d4731fce02bb9e69613d0e48c29033cad4a98/talkback/src/main/java/eventprocessor/ProcessorScrollPosition.java#L246.
This uses the
getFromIndexandgetToIndexof an accessibility record to produce the event. There is also some logic to determine the name of the page.In theory this could be supported for any List, but I'm not sure yet how it considers items that are outside of the viewport. Since we prune lists, if we wanted to handle the offscreen count we would need to provide the total number of children and current start index.
jonahwilliams commentedon Jul 19, 2018
The only change that needs to made on the engine side is trivial - add two more members describing the total number of children and the index of the first node in the child array, then Talkback handles the rest:
The difficulty I've had is how exactly to get this information onto a single semantics node. Currently the scroll events are dispatched from the node created by
Scrollable- but this only knows about the viewport and has no concept of children. Really what I would like so for a child that knows the child count, like the SliverList to tell this scrollable the child information. Haven't found a way to do this yet.cc @goderbauer
jonahwilliams commentedon Sep 11, 2018
So I've spent some time on this and figured out there may just be too many issues blocking a fully general automagic solution for CustomScrollView:
Even though all of the bits are there, they are spread out and not always available at the right time. I've prototyped some solutions that work by encoding the values into the semantics tree, but it quickly becomes very cumbersome - i.e. traversing 2 or 3 levels of semantics nodes to collect information. I don't feel confident that this is actually a generally solution.
As an alternative we could not fix it, but I think this degrades the accessibility experience for fairly common cases like ListViews. My solution is fairly simple, but requires developer specific for more complex cases.
CustomScrollView takes an 'int scroll(semantics)Children' parameter which declares the total number of scroll children which contribute semantics. This can be supplied by default for ListView.
For indexes we require the user to wrap children in a SemanticsIndex(child: child, index: index). This can be done automatically for ListView. This does run the risk of marking dividers as important for semantics, but I still think this is better than the alternative.
We can still try and work on a better API, or perhaps find more cases where we can automatically infer indexes in the mean time.
Would appreciate any thoughts on this: @goderbauer, @yjbanov
github-actions commentedon Aug 15, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.