Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] automaticallyAdjustKeyboardInsets not shifting scrollview content #46732

Closed
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Opt code
  • Loading branch information
zhongwuzw committed Oct 2, 2024
commit cbe920ba92152f4859c5c9d19a31a28f64e3be68
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ @implementation RCTBaseTextInputView {

- (void)reactUpdateResponderOffsetForScrollView:(RCTScrollView *)scrollView
{
scrollView.firstResponderFocusView = self.backedTextInputView;
if (![self isDescendantOfView:scrollView]) {
// View is outside scroll view
scrollView.firstResponderViewOffScrollView = self.backedTextInputView;
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ 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 relative to the window to compare against UIKeyboardFrameBegin/End */
@property (nonatomic, weak) UIView *firstResponderFocusView;
/** newly-activated text input outside of the scroll view */
@property (nonatomic, weak) UIView *firstResponderViewOffScrollView;
zhongwuzw marked this conversation as resolved.
Show resolved Hide resolved

/*
* Returns the subview of the scroll view that the component uses to mount all subcomponents into. That's useful to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ - (void)_keyboardWillChangeFrame:(NSNotification *)notification
from:self
forEvent:nil]) {
if (CGRectEqualToRect(_firstResponderFocus, CGRectNull)) {
UIView *inputAccessoryView = _firstResponderFocusView.inputAccessoryView;
UIView *inputAccessoryView = _firstResponderViewOffScrollView.inputAccessoryView;
if (inputAccessoryView) {
// Text input view is within the inputAccessoryView.
contentDiff = keyboardEndFrame.origin.y - keyboardBeginFrame.origin.y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ - (void)didMoveToWindow

- (void)reactUpdateResponderOffsetForScrollView:(RCTScrollViewComponentView *)scrollView
{
scrollView.firstResponderFocusView = _backedTextInputView;
if (![self isDescendantOfView:scrollView.scrollView] || !_backedTextInputView.isFirstResponder) {
// View is outside scroll view or it's not a first responder.
scrollView.firstResponderViewOffScrollView = _backedTextInputView;
return;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-native/React/Views/ScrollView/RCTScrollView.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +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 relative to the window to compare against UIKeyboardFrameBegin/End */
@property (nonatomic, weak) UIView *firstResponderFocusView;
/** newly-activated text input outside of the scroll view */
@property (nonatomic, weak) UIView *firstResponderViewOffScrollView;

// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ - (void)_keyboardWillChangeFrame:(NSNotification *)notification
// Text field active region is below visible area with keyboard - update diff to bring into view
contentDiff = endFrame.origin.y - focusEnd;
} else {
UIView *inputAccessoryView = _firstResponderFocusView.inputAccessoryView;
UIView *inputAccessoryView = _firstResponderViewOffScrollView.inputAccessoryView;
if (inputAccessoryView) {
// Text input view is within the inputAccessoryView.
contentDiff = endFrame.origin.y - beginFrame.origin.y;
Expand Down
Loading