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: https://github.com/facebook/react-native/pull/24641 Differential Revision: D15120211 Pulled By: cpojer fbshipit-source-id: 7996ab9f9b78588fab4986c3de6114817ec37296
This commit is contained in:
parent
39776a82f0
commit
0a3bbcd1b2
|
@ -289,16 +289,16 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|||
|
||||
- (void)setSecureTextEntry:(BOOL)secureTextEntry {
|
||||
UIView<RCTBackedTextInputViewProtocol> *textInputView = self.backedTextInputView;
|
||||
|
||||
|
||||
if (textInputView.secureTextEntry != secureTextEntry) {
|
||||
textInputView.secureTextEntry = secureTextEntry;
|
||||
|
||||
|
||||
// Fix #5859, see https://stackoverflow.com/questions/14220187/uitextfield-has-trailing-whitespace-after-securetextentry-toggle/22537788#22537788
|
||||
NSAttributedString *originalText = [textInputView.attributedText copy];
|
||||
self.backedTextInputView.attributedText = [NSAttributedString new];
|
||||
self.backedTextInputView.attributedText = originalText;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#pragma mark - RCTBackedTextInputDelegate
|
||||
|
@ -405,7 +405,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|||
}
|
||||
|
||||
NSString *previousText = backedTextInputView.attributedText.string ?: @"";
|
||||
|
||||
|
||||
if (range.location + range.length > backedTextInputView.attributedText.string.length) {
|
||||
_predictedText = backedTextInputView.attributedText.string;
|
||||
} else {
|
||||
|
@ -511,13 +511,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|||
return fittingSize;
|
||||
}
|
||||
|
||||
#pragma mark - Accessibility
|
||||
|
||||
- (UIView *)reactAccessibilityElement
|
||||
{
|
||||
return self.backedTextInputView;
|
||||
}
|
||||
|
||||
#pragma mark - Focus Control
|
||||
|
||||
- (void)reactFocus
|
||||
|
|
|
@ -34,6 +34,7 @@ RCT_EXPORT_MODULE()
|
|||
|
||||
#pragma mark - Unified <TextInput> properties
|
||||
|
||||
RCT_REMAP_VIEW_PROPERTY(accessibilityLabel, reactAccessibilityElement.accessibilityLabel, NSString)
|
||||
RCT_REMAP_VIEW_PROPERTY(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType)
|
||||
RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType)
|
||||
RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL)
|
||||
|
|
Loading…
Reference in New Issue