mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
automaticallyAdjustKeyboardInsets not shifting scrollview content (#46732)
Summary: Fixes https://github.com/facebook/react-native/issues/46595 . It seems https://github.com/facebook/react-native/issues/37766 broke the `automaticallyAdjustKeyboardInsets` when input accessory view become first responder. [IOS] [FIXED] - automaticallyAdjustKeyboardInsets not shifting scrollview content Pull Request resolved: https://github.com/facebook/react-native/pull/46732 Test Plan: Repro please see in #https://github.com/facebook/react-native/issues/46595 . Reviewed By: cipolleschi Differential Revision: D65072478 Pulled By: javache fbshipit-source-id: 7d5d7566438d4bb0e1d50074a953b18866e324d3
This commit is contained in:
committed by
Blake Friedman
parent
94e2b5b1b4
commit
08976e46da
@@ -36,6 +36,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
||||
{
|
||||
if (![self isDescendantOfView:scrollView]) {
|
||||
// View is outside scroll view
|
||||
scrollView.firstResponderViewOutsideScrollView = self.backedTextInputView;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -38,6 +38,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
/** Focus area of newly-activated text input relative to the window to compare against UIKeyboardFrameBegin/End */
|
||||
@property (nonatomic, assign) CGRect firstResponderFocus;
|
||||
|
||||
/** newly-activated text input outside of the scroll view */
|
||||
@property (nonatomic, weak) UIView *firstResponderViewOutsideScrollView;
|
||||
|
||||
/*
|
||||
* Returns the subview of the scroll view that the component uses to mount all subcomponents into. That's useful to
|
||||
* separate component views from auxiliary views to be able to reliably implement pull-to-refresh- and RTL-related
|
||||
|
||||
+1
@@ -182,6 +182,7 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrollView, NSInt
|
||||
UIViewAnimationCurve curve =
|
||||
(UIViewAnimationCurve)[notification.userInfo[UIKeyboardAnimationCurveUserInfoKey] unsignedIntegerValue];
|
||||
CGRect keyboardEndFrame = [notification.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
|
||||
CGRect keyboardBeginFrame = [notification.userInfo[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
|
||||
|
||||
CGPoint absoluteViewOrigin = [self convertPoint:self.bounds.origin toView:nil];
|
||||
CGFloat scrollViewLowerY = isInverted ? absoluteViewOrigin.y : absoluteViewOrigin.y + self.bounds.size.height;
|
||||
|
||||
+1
@@ -126,6 +126,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
|
||||
{
|
||||
if (![self isDescendantOfView:scrollView.scrollView] || !_backedTextInputView.isFirstResponder) {
|
||||
// View is outside scroll view or it's not a first responder.
|
||||
scrollView.firstResponderViewOutsideScrollView = _backedTextInputView;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
@property (nonatomic, assign) BOOL inverted;
|
||||
/** Focus area of newly-activated text input relative to the window to compare against UIKeyboardFrameBegin/End */
|
||||
@property (nonatomic, assign) CGRect firstResponderFocus;
|
||||
/** newly-activated text input outside of the scroll view */
|
||||
@property (nonatomic, weak) UIView *firstResponderViewOutsideScrollView;
|
||||
|
||||
// NOTE: currently these event props are only declared so we can export the
|
||||
// event names to JS - we don't call the blocks directly because scroll events
|
||||
|
||||
@@ -338,6 +338,12 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
|
||||
if (!didFocusExternalTextField && focusEnd > endFrame.origin.y) {
|
||||
// Text field active region is below visible area with keyboard - update diff to bring into view
|
||||
contentDiff = endFrame.origin.y - focusEnd;
|
||||
} else {
|
||||
UIView *inputAccessoryView = _firstResponderViewOutsideScrollView.inputAccessoryView;
|
||||
if (inputAccessoryView) {
|
||||
// Text input view is within the inputAccessoryView.
|
||||
contentDiff = endFrame.origin.y - beginFrame.origin.y;
|
||||
}
|
||||
}
|
||||
} else if (endFrame.origin.y <= beginFrame.origin.y) {
|
||||
// Keyboard opened for other reason
|
||||
|
||||
Reference in New Issue
Block a user