From 4f27b768e2882b37f09b3e40d2497a7adcc90a4a Mon Sep 17 00:00:00 2001 From: Tyler Hedrick Date: Tue, 15 Aug 2017 14:42:28 -0700 Subject: [PATCH] [a11y] fix VoiceOver navigation (#33) * [a11y] fix VoiceOver navigation This commit disables removeClippedSubviews for all react views when VoiceOver is enabled on iOS. The issue is that VoiceOver relys on the view hierarchy to know how to navigate between elements when the user swipes left and right. When removeClippedSubviews is enabled, all views offscreen are removed from the view hierarchy, causing VoiceOver to stop navigating when it gets to the last view rendered on screen. This PR fixes that by forcing removeClippedSubviews to be false for VoiceOver users. * [a11y] fix VoiceOver navigation This commit disables removeClippedSubviews for all react views when VoiceOver is enabled on iOS. The issue is that VoiceOver relys on the view hierarchy to know how to navigate between elements when the user swipes left and right. When removeClippedSubviews is enabled, all views offscreen are removed from the view hierarchy, causing VoiceOver to stop navigating when it gets to the last view rendered on screen. This PR fixes that by forcing removeClippedSubviews to be false for VoiceOver users. --- React/Views/RCTView.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/React/Views/RCTView.m b/React/Views/RCTView.m index c434a0290784d3..78d59fc0a61adc 100644 --- a/React/Views/RCTView.m +++ b/React/Views/RCTView.m @@ -370,6 +370,12 @@ - (void)react_updateClippedSubviewsWithClipRect:(CGRect)clipRect relativeToView: - (void)setRemoveClippedSubviews:(BOOL)removeClippedSubviews { + // removeClippedSubviews prevents VoiceOver from navigating through scrollViews properly, + // so we always disable removing clipped subviews when VoiceOver is active. + if (UIAccessibilityIsVoiceOverRunning()) { + RCTLogInfo(@"removeClippedSubviews is disabled when VoiceOver is active"); + removeClippedSubviews = NO; + } if (!removeClippedSubviews && _removeClippedSubviews) { [self react_remountAllSubviews]; }