Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 998c5be

Browse files
committed
Revert "fix On iOS, dialog titles are announced twice (#19826)"
This reverts commit 48a6fde.
1 parent 48687ca commit 998c5be

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

shell/platform/darwin/ios/framework/Source/SemanticsObject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ constexpr int32_t kRootNodeId = 0;
9393
- (BOOL)nodeWillCauseScroll:(const flutter::SemanticsNode*)node;
9494
- (BOOL)nodeShouldTriggerAnnouncement:(const flutter::SemanticsNode*)node;
9595
- (void)collectRoutes:(NSMutableArray<SemanticsObject*>*)edges;
96-
- (SemanticsObject*)routeFocusObject;
96+
- (NSString*)routeName;
9797
- (BOOL)onCustomAccessibilityAction:(FlutterCustomAccessibilityAction*)action;
9898

9999
@end

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,20 @@ - (BOOL)onCustomAccessibilityAction:(FlutterCustomAccessibilityAction*)action {
282282
return YES;
283283
}
284284

285-
- (SemanticsObject*)routeFocusObject {
286-
// Returns the first SemanticObject in this branch that has
287-
// the NamesRoute flag with a non-nil semantic label. Otherwise
288-
// returns nil.
285+
- (NSString*)routeName {
286+
// Returns the first non-null and non-empty semantic label of a child
287+
// with an NamesRoute flag. Otherwise returns nil.
289288
if ([self node].HasFlag(flutter::SemanticsFlags::kNamesRoute)) {
290289
NSString* newName = [self accessibilityLabel];
291290
if (newName != nil && [newName length] > 0) {
292-
return self;
291+
return newName;
293292
}
294293
}
295294
if ([self hasChildren]) {
296295
for (SemanticsObject* child in self.children) {
297-
SemanticsObject* focusObject = [child routeFocusObject];
298-
if (focusObject != nil) {
299-
return focusObject;
296+
NSString* newName = [child routeName];
297+
if (newName != nil && [newName length] > 0) {
298+
return newName;
300299
}
301300
}
302301
}

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,11 @@ void PostAccessibilityNotification(UIAccessibilityNotifications notification,
197197
layoutChanged = layoutChanged || [doomed_uids count] > 0;
198198
// We should send out only one notification per semantics update.
199199
if (routeChanged) {
200+
200201
if (!ios_delegate_->IsFlutterViewControllerPresentingModalViewController(view_controller_)) {
201-
SemanticsObject* nextToFocus = [lastAdded routeFocusObject];
202-
if (!nextToFocus && root) {
203-
nextToFocus = FindFirstFocusable(root);
204-
}
202+
NSString* routeName = [lastAdded routeName];
205203
ios_delegate_->PostAccessibilityNotification(UIAccessibilityScreenChangedNotification,
206-
nextToFocus);
204+
routeName);
207205
}
208206
} else if (layoutChanged) {
209207
SemanticsObject* nextToFocus = nil;

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,7 @@ - (void)testAnnouncesRouteChanges {
328328
bridge->UpdateSemantics(/*nodes=*/nodes, /*actions=*/actions);
329329

330330
XCTAssertEqual([accessibility_notifications count], 1ul);
331-
SemanticsObject* focusObject = accessibility_notifications[0][@"argument"];
332-
XCTAssertEqual([focusObject uid], 3);
333-
XCTAssertEqualObjects([focusObject accessibilityLabel], @"node3");
331+
XCTAssertEqualObjects(accessibility_notifications[0][@"argument"], @"route");
334332
XCTAssertEqual([accessibility_notifications[0][@"notification"] unsignedIntValue],
335333
UIAccessibilityScreenChangedNotification);
336334
}

0 commit comments

Comments
 (0)