Skip to content

Commit 8798130

Browse files
committed
Apply requested code format changes
1 parent 5e895f2 commit 8798130

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.m

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
#import <React/RCTTextAttributes.h>
2121
#import <React/RCTTextSelection.h>
2222

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;
2425

2526
@implementation RCTBaseTextInputView {
2627
__weak RCTBridge *_bridge;
@@ -41,18 +42,17 @@ - (void)reactUpdateResponderOffsetForScrollView:(RCTScrollView *)scrollView
4142
UITextSelectionRect *selection = [self.backedTextInputView selectionRectsForRange:selectedTextRange].firstObject;
4243
if (selection == nil) {
4344
// 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];
4655
}
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];
5656
}
5757

5858
- (instancetype)initWithBridge:(RCTBridge *)bridge

packages/react-native/React/Views/ScrollView/RCTScrollView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ - (void)_keyboardWillChangeFrame:(NSNotification *)notification
330330
CGFloat contentDiff = 0;
331331
if ([[UIApplication sharedApplication] sendAction:@selector(reactUpdateResponderOffsetForScrollView:) to:nil from:self forEvent:nil]) {
332332
// Inner text field focused
333-
CGFloat focusEnd = self.firstResponderFocus.origin.y + self.firstResponderFocus.size.height;
333+
CGFloat focusEnd = CGRectGetMaxY(self.firstResponderFocus);
334334
if (focusEnd > endFrame.origin.y && focusEnd != INFINITY) {
335335
// Text field active region is below visible area with keyboard - update diff to bring into view
336336
contentDiff = endFrame.origin.y - focusEnd;

0 commit comments

Comments
 (0)