Skip to content

Commit 9baf589

Browse files
authored
[iOS] [a11y] Don't allow scroll views to grab a11y focus (flutter#9282)
1 parent f80ac5f commit 9baf589

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/ui/semantics/semantics_node.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ enum class SemanticsFlags : int32_t {
7171
kHasImplicitScrolling = 1 << 18,
7272
};
7373

74+
const int kScrollableSemanticsFlags =
75+
static_cast<int32_t>(SemanticsFlags::kHasImplicitScrolling);
76+
7477
struct SemanticsNode {
7578
SemanticsNode();
7679

shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,16 @@ - (BOOL)isAccessibilityElement {
171171
if ([self node].HasFlag(flutter::SemanticsFlags::kScopesRoute))
172172
return false;
173173

174-
return ([self node].flags != 0 &&
174+
// If the only flag(s) set are scrolling related AND
175+
// The only flags set are not kIsHidden OR
176+
// The node doesn't have a label, value, or hint OR
177+
// The only actions set are scrolling related actions.
178+
//
179+
// The kIsHidden flag set with any other flag just means this node is now
180+
// hidden but still is a valid target for a11y focus in the tree, e.g. a list
181+
// item that is currently off screen but the a11y navigation needs to know
182+
// about.
183+
return (([self node].flags & ~flutter::kScrollableSemanticsFlags) != 0 &&
175184
[self node].flags != static_cast<int32_t>(flutter::SemanticsFlags::kIsHidden)) ||
176185
![self node].label.empty() || ![self node].value.empty() || ![self node].hint.empty() ||
177186
([self node].actions & ~flutter::kScrollableSemanticsActions) != 0;

0 commit comments

Comments
 (0)