mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
fix On iOS, dialog titles are announced twice (flutter/engine#19826)
This commit is contained in:
parent
adeb2599ce
commit
971aa24aae
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user