Skip to content

Commit 8a20e2c

Browse files
committed
[TextInput] Fix macOS support for setting selection
1 parent 45f680f commit 8a20e2c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Libraries/Text/TextInput/RCTBaseTextInputView.m

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ - (void)setSelection:(RCTTextSelection *)selection
235235
- (void)setSelectionStart:(NSInteger)start
236236
selectionEnd:(NSInteger)end
237237
{
238-
#if !TARGET_OS_OSX // [TODO(macOS v0.63)
238+
#if !TARGET_OS_OSX // TODO(macOS ISS#2323203)
239239
UITextPosition *startPosition = [self.backedTextInputView positionFromPosition:self.backedTextInputView.beginningOfDocument
240240
offset:start];
241241
UITextPosition *endPosition = [self.backedTextInputView positionFromPosition:self.backedTextInputView.beginningOfDocument
@@ -244,7 +244,11 @@ - (void)setSelectionStart:(NSInteger)start
244244
UITextRange *range = [self.backedTextInputView textRangeFromPosition:startPosition toPosition:endPosition];
245245
[self.backedTextInputView setSelectedTextRange:range notifyDelegate:NO];
246246
}
247-
#endif // ]TODO(macOS v0.63)
247+
#else // [TODO(macOS ISS#2323203)
248+
NSInteger startPosition = MIN(start, end);
249+
NSInteger endPosition = MAX(start, end);
250+
[self.backedTextInputView setSelectedTextRange:NSMakeRange(startPosition, endPosition - startPosition) notifyDelegate:NO];
251+
#endif // ]TODO(macOS ISS#2323203)
248252
}
249253

250254
- (void)setTextContentType:(NSString *)type

0 commit comments

Comments
 (0)