File tree Expand file tree Collapse file tree 1 file changed +9
-8
lines changed
packages/react-native/React/Views/ScrollView Expand file tree Collapse file tree 1 file changed +9
-8
lines changed Original file line number Diff line number Diff line change @@ -327,21 +327,22 @@ - (void)_keyboardWillChangeFrame:(NSNotification *)notification
327
327
CGPoint newContentOffset = _scrollView.contentOffset ;
328
328
self.firstResponderFocus = CGRectNull;
329
329
330
+ CGFloat contentDiff = 0 ;
330
331
if ([[UIApplication sharedApplication ] sendAction: @selector (reactUpdateResponderOffsetForScrollView: ) to: nil from: self forEvent: nil ]) {
331
332
// Inner text field focused
332
333
CGFloat focusEnd = self.firstResponderFocus .origin .y + self.firstResponderFocus .size .height ;
333
334
if (focusEnd > endFrame.origin .y && focusEnd != INFINITY) {
334
- // Text field active region is below visible area with keyboard - update offset to bring into view
335
- newContentOffset. y += focusEnd - endFrame.origin .y ;
335
+ // Text field active region is below visible area with keyboard - update diff to bring into view
336
+ contentDiff = endFrame.origin .y - focusEnd ;
336
337
}
337
338
} else if (endFrame.origin .y <= beginFrame.origin .y ) {
338
339
// Keyboard opened for other reason
339
- CGFloat contentDiff = endFrame.origin .y - beginFrame.origin .y ;
340
- if (self. inverted ) {
341
- newContentOffset. y += contentDiff;
342
- } else {
343
- newContentOffset. y -= contentDiff;
344
- }
340
+ contentDiff = endFrame.origin .y - beginFrame.origin .y ;
341
+ }
342
+ if (self. inverted ) {
343
+ newContentOffset. y += contentDiff;
344
+ } else {
345
+ newContentOffset. y -= contentDiff;
345
346
}
346
347
347
348
if (@available (iOS 14.0 , *)) {
You can’t perform that action at this time.
0 commit comments