Skip to content

Scrollviews need to announce which items of how many are shown #10595

Closed

Description

@goderbauer

In accessbility mode, a scrollable view should anounce that it is showing "Page x of y" or that it is showing "Items x to y of z total items"

Activity

  1. added this to the milestone on Dec 20, 2017
  2. jonahwilliams commented on Jul 19, 2018

    @jonahwilliams
    Contributor

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

  3. jonahwilliams commented on Jul 19, 2018

    @jonahwilliams
    Contributor

    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:

    event.setFromIndex(object.firstChildIndex);
    event.setToIndex(object.firstChildIndex + object.childrenInHitTestOrder.size() - 1);
    event.setItemCount(object.totalChildCount);

    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

  4. jonahwilliams commented on Sep 11, 2018

    @jonahwilliams
    Contributor

    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.

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

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

  5. github-actions commented on Aug 15, 2021

    @github-actions

    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.

  6. locked as resolved and limited conversation to collaborators on Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions