File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
packages/react-native/Libraries/Text/TextInput Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -40,20 +40,19 @@ - (void)reactUpdateResponderOffsetForScrollView:(RCTScrollView *)scrollView
40
40
41
41
UITextRange *selectedTextRange = self.backedTextInputView .selectedTextRange ;
42
42
UITextSelectionRect *selection = [self .backedTextInputView selectionRectsForRange: selectedTextRange].firstObject ;
43
+ CGRect focusRect;
43
44
if (selection == nil ) {
44
45
// No active selection or caret - fallback to entire input frame
45
- scrollView. firstResponderFocus = [ self convertRect: self .bounds toView: nil ] ;
46
+ focusRect = self.bounds ;
46
47
} else {
47
48
// Focus on text selection frame
49
+ focusRect = selection.rect ;
48
50
BOOL isMultiline = [self .backedTextInputView isKindOfClass: [UITextView class ]];
49
- CGRect focusRect = CGRectMake (
50
- selection.rect .origin .x ,
51
- selection.rect .origin .y ,
52
- selection.rect .size .width ,
53
- selection.rect .size .height + (isMultiline ? 0 : kSingleLineKeyboardBottomOffset )
54
- );
55
- scrollView.firstResponderFocus = [self convertRect: focusRect toView: nil ];
51
+ if (!isMultiline) {
52
+ focusRect.size .height += kSingleLineKeyboardBottomOffset ;
53
+ }
56
54
}
55
+ scrollView.firstResponderFocus = [self convertRect: focusRect toView: nil ];
57
56
}
58
57
59
58
- (instancetype )initWithBridge : (RCTBridge *)bridge
You can’t perform that action at this time.
0 commit comments