Skip to content

Commit 31d214c

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

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

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

Lines changed: 22 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;
54+
return (view.accessibilityTraits & interactiveTraits) != 0;
55+
}
56+
#endif
57+
4158
@implementation RCTViewComponentView {
4259
UIColor *_backgroundColor;
4360
CALayer *_backgroundColorLayer;
@@ -1490,6 +1507,11 @@ - (BOOL)wantsToCooptLabel
14901507

14911508
- (BOOL)canBecomeFocused
14921509
{
1510+
#if !TARGET_OS_TV
1511+
if (RCTViewIsInteractiveAccessibilityElement(self)) {
1512+
return YES;
1513+
}
1514+
#endif
14931515
return _focusable;
14941516
}
14951517

0 commit comments

Comments
 (0)