Skip to content

Commit a9a392c

Browse files
sbuggayfacebook-github-bot
authored andcommitted
Fix keyboard focus for Marketplace You page interactive rows (#57750)
Summary: Changelog: [Internal] Fixes iOS Full Keyboard Access (FKA) not focusing interactive rows on the Marketplace You page. Differential Revision: D113967090
1 parent 1208178 commit a9a392c

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,23 @@
3838

3939
const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
4040

41+
#if !TARGET_OS_TV
42+
// iOS Full Keyboard Access only focuses a view when it is an accessibility
43+
// element that also exposes an interactive trait. Views that surface their
44+
// interactivity through a grouping accessibility element (rather than the
45+
// underlying control) are otherwise skipped by the focus engine, leaving
46+
// keyboard-only users unable to reach them.
47+
static BOOL RCTViewIsInteractiveAccessibilityElement(UIView *view)
48+
{
49+
if (!view.isAccessibilityElement) {
50+
return NO;
51+
}
52+
UIAccessibilityTraits interactiveTraits = UIAccessibilityTraitButton | UIAccessibilityTraitLink |
53+
UIAccessibilityTraitSearchField | UIAccessibilityTraitKeyboardKey | UIAccessibilityTraitAdjustable;
54+
return (view.accessibilityTraits & interactiveTraits) != 0;
55+
}
56+
#endif
57+
4158
@implementation RCTViewComponentView {
4259
UIColor *_backgroundColor;
4360
CALayer *_backgroundColorLayer;
@@ -1490,7 +1507,11 @@ - (BOOL)wantsToCooptLabel
14901507

14911508
- (BOOL)canBecomeFocused
14921509
{
1510+
#if !TARGET_OS_TV
1511+
return RCTViewIsInteractiveAccessibilityElement(self) || _focusable;
1512+
#else
14931513
return _focusable;
1514+
#endif
14941515
}
14951516

14961517
- (BOOL)isAccessibilityElement

0 commit comments

Comments
 (0)