diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm index 2b6dfd9dde..e864cc463a 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm @@ -941,7 +941,12 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) { } - (CGRect)accessibilityFrame { - return self.semanticsObject.accessibilityFrame; + // For OverlayPortals, the child element is sometimes outside the bounds of the parent + // Even if it's marked accessible, VoiceControl labels will not appear if it's too + // spatially distant. Set the frame to be the max screen size so all children are guaraenteed + // to be contained. + + return UIScreen.mainScreen.bounds; } - (id)accessibilityContainer { diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm index 02fb11f983..b91d83cfef 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -614,6 +614,41 @@ const float kFloatCompareEpsilon = 0.001; XCTAssertTrue([object.accessibilityLabel isEqualToString:@"label\ntooltip"]); } +- (void)testSemanticsObjectContainerAccessibilityFrameCoversEntireScreen { + flutter::testing::MockAccessibilityBridge* mock = new flutter::testing::MockAccessibilityBridge(); + mock->isVoiceOverRunningValue = true; + fml::WeakPtrFactory factory(mock); + fml::WeakPtr bridge = factory.GetWeakPtr(); + + flutter::SemanticsNode parent; + parent.id = 0; + parent.actions = static_cast(flutter::SemanticsAction::kTap); + + flutter::SemanticsNode child; + child.id = 1; + child.actions = static_cast(flutter::SemanticsAction::kTap); + child.rect = SkRect::MakeXYWH(0, 0, 100, 100); + parent.childrenInTraversalOrder.push_back(1); + + FlutterSemanticsObject* parentObject = [[FlutterSemanticsObject alloc] initWithBridge:bridge + uid:0]; + [parentObject setSemanticsNode:&parent]; + + FlutterSemanticsObject* childObject = [[FlutterSemanticsObject alloc] initWithBridge:bridge + uid:1]; + [childObject setSemanticsNode:&child]; + + parentObject.children = @[ childObject ]; + [parentObject accessibilityBridgeDidFinishUpdate]; + [childObject accessibilityBridgeDidFinishUpdate]; + + SemanticsObjectContainer* container = + static_cast(parentObject.accessibilityContainer); + + XCTAssertTrue(childObject.accessibilityRespondsToUserInteraction); + XCTAssertTrue(CGRectEqualToRect(container.accessibilityFrame, UIScreen.mainScreen.bounds)); +} + - (void)testFlutterSemanticsObjectAttributedStringsDoNotCrashWhenEmpty { flutter::testing::MockAccessibilityBridge* mock = new flutter::testing::MockAccessibilityBridge(); mock->isVoiceOverRunningValue = true;