Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Libraries/Text/TextInput/Multiline/RCTUITextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,12 @@ - (BOOL)becomeFirstResponder

- (BOOL)resignFirstResponder
{
BOOL success = [super resignFirstResponder];
if (self.selectable) {
self.selectedRange = NSMakeRange(NSNotFound, 0);
}

BOOL success = [super resignFirstResponder];

if (success) {
// Break undo coalescing when losing focus.
[self breakUndoCoalescing];
Expand Down Expand Up @@ -436,13 +440,13 @@ - (void)selectAll:(id)sender
{
[super selectAll:sender];

#if !TARGET_OS_OSX // TODO(macOS GH#774) For `selectTextOnFocus` prop, which isn't supported on macOS atm.
#if !TARGET_OS_OSX // TODO(macOS GH#774)
// `selectAll:` does not work for UITextView when it's being called inside UITextView's delegate methods.
dispatch_async(dispatch_get_main_queue(), ^{
UITextRange *selectionRange = [self textRangeFromPosition:self.beginningOfDocument toPosition:self.endOfDocument];
[self setSelectedTextRange:selectionRange notifyDelegate:NO];
});
#endif
#endif // TODO(macOS GH#774)
}

#pragma mark - Layout
Expand Down
8 changes: 7 additions & 1 deletion Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,13 @@ - (void)textInputDidBeginEditing
}

if (_selectTextOnFocus) {
[self.backedTextInputView selectAll:nil];
if ([self.backedTextInputView respondsToSelector:@selector(selectAll:)]) {
[self.backedTextInputView selectAll:nil];
}
#if TARGET_OS_OSX // [TODO(macOS GH#774)
} else {
[self.backedTextInputView setSelectedTextRange:NSMakeRange(NSNotFound, 0) notifyDelegate:NO];
#endif // ]TODO(macOS GH#774)
}

[_eventDispatcher sendTextEventWithType:RCTTextEventTypeFocus
Expand Down
4 changes: 2 additions & 2 deletions Libraries/Text/TextInput/RCTBaseTextInputViewManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ @implementation RCTBaseTextInputViewManager
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(secureTextEntry, backedTextInputView.secureTextEntry, BOOL) // TODO(macOS GH#774)
RCT_EXPORT_VIEW_PROPERTY(autoFocus, BOOL)
RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL)
RCT_EXPORT_NOT_OSX_VIEW_PROPERTY(clearTextOnFocus, BOOL) // TODO(macOS GH#774)
RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL)
RCT_REMAP_NOT_OSX_VIEW_PROPERTY(keyboardType, backedTextInputView.keyboardType, UIKeyboardType) // TODO(macOS GH#774)
RCT_EXPORT_NOT_OSX_VIEW_PROPERTY(showSoftInputOnFocus, BOOL) // TODO(macOS GH#774)
RCT_EXPORT_VIEW_PROPERTY(maxLength, NSNumber)
RCT_EXPORT_NOT_OSX_VIEW_PROPERTY(selectTextOnFocus, BOOL) // TODO(macOS GH#774)
RCT_EXPORT_VIEW_PROPERTY(selectTextOnFocus, BOOL)
RCT_EXPORT_VIEW_PROPERTY(selection, RCTTextSelection)
RCT_EXPORT_VIEW_PROPERTY(inputAccessoryViewID, NSString)
RCT_EXPORT_VIEW_PROPERTY(textContentType, NSString)
Expand Down