Skip to content

Commit

Permalink
[TextInput] Fix macOS support for setting selection
Browse files Browse the repository at this point in the history
  • Loading branch information
alloy committed Oct 8, 2020
1 parent 45f680f commit 8a20e2c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Libraries/Text/TextInput/RCTBaseTextInputView.m
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ - (void)setSelection:(RCTTextSelection *)selection
- (void)setSelectionStart:(NSInteger)start
selectionEnd:(NSInteger)end
{
#if !TARGET_OS_OSX // [TODO(macOS v0.63)
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
UITextPosition *startPosition = [self.backedTextInputView positionFromPosition:self.backedTextInputView.beginningOfDocument
offset:start];
UITextPosition *endPosition = [self.backedTextInputView positionFromPosition:self.backedTextInputView.beginningOfDocument
Expand All @@ -244,7 +244,11 @@ - (void)setSelectionStart:(NSInteger)start
UITextRange *range = [self.backedTextInputView textRangeFromPosition:startPosition toPosition:endPosition];
[self.backedTextInputView setSelectedTextRange:range notifyDelegate:NO];
}
#endif // ]TODO(macOS v0.63)
#else // [TODO(macOS ISS#2323203)
NSInteger startPosition = MIN(start, end);
NSInteger endPosition = MAX(start, end);
[self.backedTextInputView setSelectedTextRange:NSMakeRange(startPosition, endPosition - startPosition) notifyDelegate:NO];
#endif // ]TODO(macOS ISS#2323203)
}

- (void)setTextContentType:(NSString *)type
Expand Down

0 comments on commit 8a20e2c

Please sign in to comment.