Skip to content

Commit b782b6a

Browse files
authored
Navigation.showOverlay() breaks VoiceOver accessibility - background content remains accessible (#8261)
1 parent 16a6c5f commit b782b6a

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

ios/RNNCommandsHandler.mm

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,18 @@ - (void)mergeOptions:(NSString *)componentId
118118

119119
UIViewController<RNNLayoutProtocol> *vc = [_layoutManager findComponentForId:componentId];
120120
RNNNavigationOptions *newOptions = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
121-
if ([vc conformsToProtocol:@protocol(RNNLayoutProtocol)] ||
122-
[vc isKindOfClass:[RNNComponentViewController class]]) {
121+
if (vc && ([vc conformsToProtocol:@protocol(RNNLayoutProtocol)] ||
122+
[vc isKindOfClass:[RNNComponentViewController class]])) {
123123
[CATransaction begin];
124124
[CATransaction setCompletionBlock:completion];
125125

126126
[vc mergeOptions:newOptions];
127127

128128
[CATransaction commit];
129+
} else {
130+
if (completion) {
131+
completion();
132+
}
129133
}
130134
}
131135

@@ -324,10 +328,10 @@ - (void)popTo:(NSString *)componentId
324328

325329
RNNComponentViewController *vc =
326330
(RNNComponentViewController *)[_layoutManager findComponentForId:componentId];
327-
RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
328-
[vc mergeOptions:options];
329-
330331
if (vc) {
332+
RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
333+
[vc mergeOptions:options];
334+
331335
[vc.stack popTo:vc
332336
animated:[vc.resolveOptionsWithDefault.animations.pop.enable withDefault:YES]
333337
completion:^(NSArray *poppedViewControllers) {
@@ -355,25 +359,27 @@ - (void)popToRoot:(NSString *)componentId
355359

356360
RNNComponentViewController *vc =
357361
(RNNComponentViewController *)[_layoutManager findComponentForId:componentId];
358-
RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
359-
[vc mergeOptions:options];
360-
361-
[CATransaction begin];
362-
[CATransaction setCompletionBlock:^{
363-
[self->_eventEmitter sendOnNavigationCommandCompletion:popToRoot commandId:commandId];
364-
completion();
365-
}];
366-
367-
[vc.stack popToRoot:vc
368-
animated:[vc.resolveOptionsWithDefault.animations.pop.enable withDefault:YES]
369-
completion:^(NSArray *poppedViewControllers) {
370-
371-
}
372-
rejection:^(NSString *code, NSString *message, NSError *error){
373-
374-
}];
362+
if (vc) {
363+
RNNNavigationOptions *options = [[RNNNavigationOptions alloc] initWithDict:mergeOptions];
364+
[vc mergeOptions:options];
375365

376-
[CATransaction commit];
366+
[vc.stack popToRoot:vc
367+
animated:[vc.resolveOptionsWithDefault.animations.pop.enable withDefault:YES]
368+
completion:^(NSArray *poppedViewControllers) {
369+
[self->_eventEmitter sendOnNavigationCommandCompletion:popToRoot
370+
commandId:commandId];
371+
completion();
372+
}
373+
rejection:rejection];
374+
} else {
375+
[RNNErrorHandler
376+
reject:rejection
377+
withErrorCode:1012
378+
errorDescription:
379+
[NSString stringWithFormat:
380+
@"PopToRoot component failed - componentId '%@' not found",
381+
componentId]];
382+
}
377383
}
378384

379385
- (void)showModal:(NSDictionary *)layout

ios/RNNOverlayManager.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ - (void)showOverlayWindow:(RNNOverlayWindow *)overlayWindow {
1919
[overlayWindow setHidden:NO];
2020

2121
overlayWindow.previousWindow.accessibilityElementsHidden = YES;
22+
UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, overlayWindow);
2223
}
2324

2425
- (void)showOverlayWindowAsKeyWindow:(RNNOverlayWindow *)overlayWindow {
@@ -41,6 +42,7 @@ - (void)dismissAllOverlays {
4142

4243
- (void)detachOverlayWindow:(RNNOverlayWindow *)overlayWindow {
4344
overlayWindow.previousWindow.accessibilityElementsHidden = NO;
45+
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
4446

4547
[overlayWindow.previousWindow makeKeyWindow];
4648
[overlayWindow setHidden:YES];

0 commit comments

Comments
 (0)