Skip to content

Commit 598c720

Browse files
Fix disableViewCulling
1 parent 38c56b2 commit 598c720

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,23 @@ - (NSInteger)accessibilityElementCount
674674
[self _disableViewCullingIfNecessary];
675675
return [super focusItemsInRect:rect];
676676
}
677+
#else // [macOS
678+
- (NSArray *)accessibilityChildren
679+
{
680+
// macOS equivalent of accessibilityElementCount: VoiceOver calls accessibilityChildren
681+
// to enumerate child elements. Detecting this API use allows us to disable view culling
682+
// when Accessibility Inspector or VoiceOver is active.
683+
[self _disableViewCullingIfNecessary];
684+
return [super accessibilityChildren];
685+
}
686+
687+
- (id)accessibilityHitTest:(NSPoint)point
688+
{
689+
// macOS equivalent of focusItemsInRect: VoiceOver calls accessibilityHitTest:
690+
// when navigating spatially.
691+
[self _disableViewCullingIfNecessary];
692+
return [super accessibilityHitTest:point];
693+
}
677694
#endif // macOS]
678695

679696
- (void)_updateStateWithContentOffset
@@ -702,7 +719,7 @@ - (void)_updateStateWithContentOffset
702719
newData.disableViewCulling =
703720
UIAccessibilityIsVoiceOverRunning() || UIAccessibilityIsSwitchControlRunning() || isAccessibilityAPIUsed;
704721
#else // [macOS
705-
newData.disableViewCulling = isAccessibilityAPIUsed;
722+
newData.disableViewCulling = [[NSWorkspace sharedWorkspace] isVoiceOverEnabled] || isAccessibilityAPIUsed;
706723
#endif // macOS]
707724
return std::make_shared<const ScrollViewShadowNode::ConcreteState::Data>(newData);
708725
},

0 commit comments

Comments
 (0)