From 899cd81833c82839457770b4a84e487657a56d99 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Tue, 11 Jun 2019 18:02:47 -0700 Subject: [PATCH] [iOS] [a11y] Don't allow scroll views to grab a11y focus (flutter/engine#9282) --- engine/src/flutter/lib/ui/semantics/semantics_node.h | 3 +++ .../ios/framework/Source/accessibility_bridge.mm | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/lib/ui/semantics/semantics_node.h b/engine/src/flutter/lib/ui/semantics/semantics_node.h index 795d058a1f..98755b1581 100644 --- a/engine/src/flutter/lib/ui/semantics/semantics_node.h +++ b/engine/src/flutter/lib/ui/semantics/semantics_node.h @@ -71,6 +71,9 @@ enum class SemanticsFlags : int32_t { kHasImplicitScrolling = 1 << 18, }; +const int kScrollableSemanticsFlags = + static_cast(SemanticsFlags::kHasImplicitScrolling); + struct SemanticsNode { SemanticsNode(); diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm index 2dcb7384c6..baa754bb83 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm @@ -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(flutter::SemanticsFlags::kIsHidden)) || ![self node].label.empty() || ![self node].value.empty() || ![self node].hint.empty() || ([self node].actions & ~flutter::kScrollableSemanticsActions) != 0;