20
20
#import < React/RCTTextAttributes.h>
21
21
#import < React/RCTTextSelection.h>
22
22
23
- #define EMPTY_TEXT_KEYBOARD_BOTTOM_OFFSET 15 // Native iOS empty text field bottom keyboard offset amount
23
+ /* * Native iOS empty text field bottom keyboard offset amount */
24
+ static const CGFloat kEmptyKeyboardBottomOffset = 15.0 ;
24
25
25
26
@implementation RCTBaseTextInputView {
26
27
__weak RCTBridge *_bridge;
@@ -41,18 +42,17 @@ - (void)reactUpdateResponderOffsetForScrollView:(RCTScrollView *)scrollView
41
42
UITextSelectionRect *selection = [self .backedTextInputView selectionRectsForRange: selectedTextRange].firstObject ;
42
43
if (selection == nil ) {
43
44
// No active selection or caret - fallback to entire input frame
44
- scrollView.firstResponderFocus = [self convertRect: self .frame toView: nil ];
45
- return ;
45
+ scrollView.firstResponderFocus = [self convertRect: self .bounds toView: nil ];
46
+ } else {
47
+ // Focus on text selection frame
48
+ CGRect focusRect = CGRectMake (
49
+ selection.rect .origin .x ,
50
+ selection.rect .origin .y ,
51
+ selection.rect .size .width ,
52
+ selection.rect .size .height + (selectedTextRange.empty ? kEmptyKeyboardBottomOffset : 0 )
53
+ );
54
+ scrollView.firstResponderFocus = [self convertRect: focusRect toView: nil ];
46
55
}
47
-
48
- // Focus on text selection frame
49
- CGRect focusRect = CGRectMake (
50
- selection.rect .origin .x ,
51
- selection.rect .origin .y ,
52
- selection.rect .size .width ,
53
- selection.rect .size .height + (selectedTextRange.empty ? EMPTY_TEXT_KEYBOARD_BOTTOM_OFFSET : 0 )
54
- );
55
- scrollView.firstResponderFocus = [self convertRect: focusRect toView: nil ];
56
56
}
57
57
58
58
- (instancetype )initWithBridge : (RCTBridge *)bridge
0 commit comments