mirror of
https://github.com/status-im/react-native.git
synced 2025-02-23 14:48:25 +00:00
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
ded7119c9a
commit
dbf27f5211
@ -289,16 +289,16 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|||||||
|
|
||||||
- (void)setSecureTextEntry:(BOOL)secureTextEntry {
|
- (void)setSecureTextEntry:(BOOL)secureTextEntry {
|
||||||
UIView<RCTBackedTextInputViewProtocol> *textInputView = self.backedTextInputView;
|
UIView<RCTBackedTextInputViewProtocol> *textInputView = self.backedTextInputView;
|
||||||
|
|
||||||
if (textInputView.secureTextEntry != secureTextEntry) {
|
if (textInputView.secureTextEntry != secureTextEntry) {
|
||||||
textInputView.secureTextEntry = secureTextEntry;
|
textInputView.secureTextEntry = secureTextEntry;
|
||||||
|
|
||||||
// Fix #5859, see https://stackoverflow.com/questions/14220187/uitextfield-has-trailing-whitespace-after-securetextentry-toggle/22537788#22537788
|
// Fix #5859, see https://stackoverflow.com/questions/14220187/uitextfield-has-trailing-whitespace-after-securetextentry-toggle/22537788#22537788
|
||||||
NSAttributedString *originalText = [textInputView.attributedText copy];
|
NSAttributedString *originalText = [textInputView.attributedText copy];
|
||||||
self.backedTextInputView.attributedText = [NSAttributedString new];
|
self.backedTextInputView.attributedText = [NSAttributedString new];
|
||||||
self.backedTextInputView.attributedText = originalText;
|
self.backedTextInputView.attributedText = originalText;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - RCTBackedTextInputDelegate
|
#pragma mark - RCTBackedTextInputDelegate
|
||||||
@ -405,7 +405,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
NSString *previousText = backedTextInputView.attributedText.string ?: @"";
|
NSString *previousText = backedTextInputView.attributedText.string ?: @"";
|
||||||
|
|
||||||
if (range.location + range.length > backedTextInputView.attributedText.string.length) {
|
if (range.location + range.length > backedTextInputView.attributedText.string.length) {
|
||||||
_predictedText = backedTextInputView.attributedText.string;
|
_predictedText = backedTextInputView.attributedText.string;
|
||||||
} else {
|
} else {
|
||||||
@ -511,13 +511,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithFrame:(CGRect)frame)
|
|||||||
return fittingSize;
|
return fittingSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Accessibility
|
|
||||||
|
|
||||||
- (UIView *)reactAccessibilityElement
|
|
||||||
{
|
|
||||||
return self.backedTextInputView;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark - Focus Control
|
#pragma mark - Focus Control
|
||||||
|
|
||||||
- (void)reactFocus
|
- (void)reactFocus
|
||||||
|
@ -34,6 +34,7 @@ RCT_EXPORT_MODULE()
|
|||||||
|
|
||||||
#pragma mark - Unified <TextInput> properties
|
#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(autoCapitalize, backedTextInputView.autocapitalizationType, UITextAutocapitalizationType)
|
||||||
RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType)
|
RCT_REMAP_VIEW_PROPERTY(autoCorrect, backedTextInputView.autocorrectionType, UITextAutocorrectionType)
|
||||||
RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL)
|
RCT_REMAP_VIEW_PROPERTY(contextMenuHidden, backedTextInputView.contextMenuHidden, BOOL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user