Skip to content

Commit 61c5e35

Browse files
Estevão Lucasfacebook-github-bot
authored andcommitted
Fix accessibility event properties for TextInput (#24641)
Summary: When a `TextInput` receives any accessibility event prop (`onAccessibilityTap`, `onMagicTap`, `onAccessibilityEscape`, `onAccessibilityEscape`), causes a crash. <p align=center><img src=https://user-images.githubusercontent.com/20709038/56871548-84f00980-69ed-11e9-8906-0206899e5435.jpg width=300></p> [iOS] [Fixed] - Fix accessibility event properties for `TextInput` Pull Request resolved: #24641 Differential Revision: D15120211 Pulled By: cpojer fbshipit-source-id: 7996ab9f9b78588fab4986c3de6114817ec37296
1 parent ca9a55e commit 61c5e35

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

Libraries/Text/TextInput/RCTBaseTextInputView.m

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,16 @@ - (BOOL)secureTextEntry {
283283

284284
- (void)setSecureTextEntry:(BOOL)secureTextEntry {
285285
UIView<RCTBackedTextInputViewProtocol> *textInputView = self.backedTextInputView;
286-
286+
287287
if (textInputView.secureTextEntry != secureTextEntry) {
288288
textInputView.secureTextEntry = secureTextEntry;
289-
289+
290290
// Fix #5859, see https://stackoverflow.com/questions/14220187/uitextfield-has-trailing-whitespace-after-securetextentry-toggle/22537788#22537788
291291
NSAttributedString *originalText = [textInputView.attributedText copy];
292292
self.backedTextInputView.attributedText = [NSAttributedString new];
293293
self.backedTextInputView.attributedText = originalText;
294294
}
295-
295+
296296
}
297297

298298
#pragma mark - RCTBackedTextInputDelegate
@@ -399,7 +399,7 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin
399399
}
400400

401401
NSString *previousText = backedTextInputView.attributedText.string ?: @"";
402-
402+
403403
if (range.location + range.length > backedTextInputView.attributedText.string.length) {
404404
_predictedText = backedTextInputView.attributedText.string;
405405
} else {
@@ -505,13 +505,6 @@ - (CGSize)sizeThatFits:(CGSize)size
505505
return fittingSize;
506506
}
507507

508-
#pragma mark - Accessibility
509-
510-
- (UIView *)reactAccessibilityElement
511-
{
512-
return self.backedTextInputView;
513-
}
514-
515508
#pragma mark - Focus Control
516509

517510
- (void)reactFocus

Libraries/Text/TextInput/RCTBaseTextInputViewManager.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ @implementation RCTBaseTextInputViewManager
3434

3535
#pragma mark - Unified <TextInput> properties
3636

37+
RCT_REMAP_VIEW_PROPERTY(accessibilityLabel, reactAccessibilityElement.accessibilityLabel, NSString)
3738
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType)
3839
RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType)
3940
RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL)

0 commit comments

Comments
 (0)