[iOS] [a11y] Don't allow scroll views to grab a11y focus (flutter/engine#9282)

This commit is contained in:
Dan Field
2019-06-11 18:02:47 -07:00
committed by GitHub
parent e7d406fe36
commit 899cd81833
2 changed files with 13 additions and 1 deletions

View File

@@ -71,6 +71,9 @@ enum class SemanticsFlags : int32_t {
kHasImplicitScrolling = 1 << 18,
};
const int kScrollableSemanticsFlags =
static_cast<int32_t>(SemanticsFlags::kHasImplicitScrolling);
struct SemanticsNode {
SemanticsNode();

View File

@@ -171,7 +171,16 @@ flutter::SemanticsAction GetSemanticsActionForScrollDirection(
if ([self node].HasFlag(flutter::SemanticsFlags::kScopesRoute))
return false;
return ([self node].flags != 0 &&
// If the only flag(s) set are scrolling related AND
// The only flags set are not kIsHidden OR
// The node doesn't have a label, value, or hint OR
// The only actions set are scrolling related actions.
//
// The kIsHidden flag set with any other flag just means this node is now
// hidden but still is a valid target for a11y focus in the tree, e.g. a list
// item that is currently off screen but the a11y navigation needs to know
// about.
return (([self node].flags & ~flutter::kScrollableSemanticsFlags) != 0 &&
[self node].flags != static_cast<int32_t>(flutter::SemanticsFlags::kIsHidden)) ||
![self node].label.empty() || ![self node].value.empty() || ![self node].hint.empty() ||
([self node].actions & ~flutter::kScrollableSemanticsActions) != 0;