File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 20
20
#import < React/RCTTextAttributes.h>
21
21
#import < React/RCTTextSelection.h>
22
22
23
- /* * Native iOS empty text field bottom keyboard offset amount */
24
- static const CGFloat kEmptyKeyboardBottomOffset = 15.0 ;
23
+ /* * Native iOS text field bottom keyboard offset amount */
24
+ static const CGFloat kSingleLineKeyboardBottomOffset = 15.0 ;
25
25
26
26
@implementation RCTBaseTextInputView {
27
27
__weak RCTBridge *_bridge;
@@ -45,11 +45,12 @@ - (void)reactUpdateResponderOffsetForScrollView:(RCTScrollView *)scrollView
45
45
scrollView.firstResponderFocus = [self convertRect: self .bounds toView: nil ];
46
46
} else {
47
47
// Focus on text selection frame
48
+ BOOL isMultiline = [self .backedTextInputView isKindOfClass: [UITextView class ]];
48
49
CGRect focusRect = CGRectMake (
49
50
selection.rect .origin .x ,
50
51
selection.rect .origin .y ,
51
52
selection.rect .size .width ,
52
- selection.rect .size .height + (selectedTextRange. empty ? kEmptyKeyboardBottomOffset : 0 )
53
+ selection.rect .size .height + (isMultiline ? 0 : kSingleLineKeyboardBottomOffset )
53
54
);
54
55
scrollView.firstResponderFocus = [self convertRect: focusRect toView: nil ];
55
56
}
Original file line number Diff line number Diff line change @@ -331,7 +331,8 @@ - (void)_keyboardWillChangeFrame:(NSNotification *)notification
331
331
if ([[UIApplication sharedApplication ] sendAction: @selector (reactUpdateResponderOffsetForScrollView: ) to: nil from: self forEvent: nil ]) {
332
332
// Inner text field focused
333
333
CGFloat focusEnd = CGRectGetMaxY (self.firstResponderFocus );
334
- if (focusEnd > endFrame.origin .y && focusEnd != INFINITY) {
334
+ BOOL didFocusExternalTextField = focusEnd == INFINITY;
335
+ if (!didFocusExternalTextField && focusEnd > endFrame.origin .y ) {
335
336
// Text field active region is below visible area with keyboard - update diff to bring into view
336
337
contentDiff = endFrame.origin .y - focusEnd;
337
338
}
You can’t perform that action at this time.
0 commit comments