forked from firka/flutter
Correct issues in visible children determination (flutter/engine#6455)
* fix off by one * add documentation on counting for setToIndex
This commit is contained in:
@@ -726,13 +726,20 @@ class AccessibilityBridge
|
||||
// handle hidden children at the beginning and end of the list.
|
||||
for (SemanticsObject child : object.childrenInHitTestOrder) {
|
||||
if (!child.hasFlag(Flag.IS_HIDDEN)) {
|
||||
break;
|
||||
visibleChildren += 1;
|
||||
}
|
||||
visibleChildren += 1;
|
||||
}
|
||||
assert(object.scrollIndex + visibleChildren <= object.scrollChildren);
|
||||
assert(!object.childrenInHitTestOrder.get(object.scrollIndex).hasFlag(Flag.IS_HIDDEN));
|
||||
event.setToIndex(object.scrollIndex + visibleChildren);
|
||||
// The setToIndex should be the index of the last visible child. Because we counted all
|
||||
// children, including the first index we need to subtract one.
|
||||
//
|
||||
// [0, 1, 2, 3, 4, 5]
|
||||
// ^ ^
|
||||
// In the example above where 0 is the first visible index and 2 is the last, we will
|
||||
// count 3 total visible children. We then subtract one to get the correct last visible
|
||||
// index of 2.
|
||||
event.setToIndex(object.scrollIndex + visibleChildren - 1);
|
||||
}
|
||||
sendAccessibilityEvent(event);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user