未验证 提交 48a6fde3 编写于 作者: C chunhtai 提交者: GitHub

fix On iOS, dialog titles are announced twice (#19826)

上级 8825f917
......@@ -93,7 +93,7 @@ constexpr int32_t kRootNodeId = 0;
- (BOOL)nodeWillCauseScroll:(const flutter::SemanticsNode*)node;
- (BOOL)nodeShouldTriggerAnnouncement:(const flutter::SemanticsNode*)node;
- (void)collectRoutes:(NSMutableArray<SemanticsObject*>*)edges;
- (NSString*)routeName;
- (SemanticsObject*)routeFocusObject;
- (BOOL)onCustomAccessibilityAction:(FlutterCustomAccessibilityAction*)action;
@end
......
......@@ -282,20 +282,21 @@ flutter::SemanticsAction GetSemanticsActionForScrollDirection(
return YES;
}
- (NSString*)routeName {
// Returns the first non-null and non-empty semantic label of a child
// with an NamesRoute flag. Otherwise returns nil.
- (SemanticsObject*)routeFocusObject {
// Returns the first SemanticObject in this branch that has
// the NamesRoute flag with a non-nil semantic label. Otherwise
// returns nil.
if ([self node].HasFlag(flutter::SemanticsFlags::kNamesRoute)) {
NSString* newName = [self accessibilityLabel];
if (newName != nil && [newName length] > 0) {
return newName;
return self;
}
}
if ([self hasChildren]) {
for (SemanticsObject* child in self.children) {
NSString* newName = [child routeName];
if (newName != nil && [newName length] > 0) {
return newName;
SemanticsObject* focusObject = [child routeFocusObject];
if (focusObject != nil) {
return focusObject;
}
}
}
......
......@@ -199,9 +199,8 @@ void AccessibilityBridge::UpdateSemantics(flutter::SemanticsNodeUpdates nodes,
layoutChanged = layoutChanged || [doomed_uids count] > 0;
if (routeChanged) {
if (!ios_delegate_->IsFlutterViewControllerPresentingModalViewController(view_)) {
NSString* routeName = [lastAdded routeName];
ios_delegate_->PostAccessibilityNotification(UIAccessibilityScreenChangedNotification,
routeName);
[lastAdded routeFocusObject]);
}
} else if (layoutChanged) {
// TODO(goderbauer): figure out which node to focus next.
......
......@@ -311,7 +311,9 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(std::string name) {
bridge->UpdateSemantics(/*nodes=*/nodes, /*actions=*/actions);
XCTAssertEqual([accessibility_notifications count], 1ul);
XCTAssertEqualObjects(accessibility_notifications[0][@"argument"], @"route");
SemanticsObject* focusObject = accessibility_notifications[0][@"argument"];
XCTAssertEqual([focusObject uid], 1);
XCTAssertEqualObjects([focusObject accessibilityLabel], @"route");
XCTAssertEqual([accessibility_notifications[0][@"notification"] unsignedIntValue],
UIAccessibilityScreenChangedNotification);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册