Skip to content

Commit

Permalink
Fix VoiceOver for single-line TextInput (#1271)
Browse files Browse the repository at this point in the history
This adds the appropriate override for AppKit (`setAccessibilityElement:`) so that the `NSTextField` will not get set to be accessible, since its cell instead is already accessible and performs the correct VoiceOver behaviors.

VoiceOver now reads as you type in a single-line `TextInput`

Co-authored-by: Scott Kyle <skyle@fb.com>
  • Loading branch information
2 people authored and chiuam committed Jul 25, 2022
1 parent ffa3c99 commit 7815f3c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Libraries/Text/TextInput/Singleline/RCTUITextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ - (instancetype)initWithFrame:(CGRect)frame
#if TARGET_OS_OSX // [TODO(macOS GH#774)
[self setBordered:NO];
[self setAllowsEditingTextAttributes:YES];
[self setAccessibilityRole:NSAccessibilityTextFieldRole];
[self setBackgroundColor:[NSColor clearColor]];
#endif // ]TODO(macOS GH#774)

Expand All @@ -127,7 +126,11 @@ - (void)_textDidChange

#pragma mark - Accessibility

#if !TARGET_OS_OSX // [TODO(macOS GH#774)
- (void)setIsAccessibilityElement:(BOOL)isAccessibilityElement
#else
- (void)setAccessibilityElement:(BOOL)isAccessibilityElement
#endif // ]TODO(macOS GH#774)
{
// UITextField is accessible by default (some nested views are) and disabling that is not supported.
// On iOS accessible elements cannot be nested, therefore enabling accessibility for some container view
Expand Down

0 comments on commit 7815f3c

Please sign in to comment.