Skip to content

Commit

Permalink
Fix accessibility event properties for TextInput (#24641)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Estevão Lucas authored and kelset committed Jun 5, 2019
1 parent ded7119 commit dbf27f5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
15 changes: 4 additions & 11 deletions Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -289,16 +289,16 @@ - (BOOL)secureTextEntry {

- (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
Expand Down Expand Up @@ -405,7 +405,7 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin
}

NSString *previousText = backedTextInputView.attributedText.string ?: @"";

if (range.location + range.length > backedTextInputView.attributedText.string.length) {
_predictedText = backedTextInputView.attributedText.string;
} else {
Expand Down Expand Up @@ -511,13 +511,6 @@ - (CGSize)sizeThatFits:(CGSize)size
return fittingSize;
}

#pragma mark - Accessibility

- (UIView *)reactAccessibilityElement
{
return self.backedTextInputView;
}

#pragma mark - Focus Control

- (void)reactFocus
Expand Down
1 change: 1 addition & 0 deletions Libraries/Text/TextInput/RCTBaseTextInputViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ @implementation RCTBaseTextInputViewManager

#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)
Expand Down

0 comments on commit dbf27f5

Please sign in to comment.