Skip to content

Commit

Permalink
fix: patch code to avoid bug with measuring layout using the scroll v…
Browse files Browse the repository at this point in the history
…iew manager

Ref to #1017 (comment)
  • Loading branch information
flochtililoch committed Feb 13, 2025
1 parent 2d2afa2 commit 81fad01
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import React, { PureComponent } from 'react';
import ReactNative, {
DeviceEventEmitter,
NativeModules,
Keyboard,
ScrollView,
} from 'react-native';
Expand All @@ -16,8 +15,6 @@ import type {
NativeScrollEvent,
} from 'react-native';

const ScrollViewManager = NativeModules.ScrollViewManager;

const defaultScrollToInputAdditionalOffset = 75;

export default class KeyboardAwareScrollView extends PureComponent<
Expand Down Expand Up @@ -86,13 +83,13 @@ export default class KeyboardAwareScrollView extends PureComponent<
};

updateKeyboardAwareViewContentSize = () => {
if (ScrollViewManager && ScrollViewManager.getContentSize) {
ScrollViewManager.getContentSize(
ReactNative.findNodeHandle(this.keyboardAwareView),
(res: { width: number; height: number }) => {
if (this.keyboardAwareView) {
// @ts-ignore: TODO(TS): fix this
this.keyboardAwareView.measure(
(x: number, y: number, width: number, height: number) => {
if (this.keyboardAwareView) {
// @ts-ignore: TODO(TS): fix this
this.keyboardAwareView.contentSize = res;
this.keyboardAwareView.contentSize = { width, height };
if (this.state.scrollBottomOnNextSizeChange) {
this.scrollToBottom();
this.setState({ scrollBottomOnNextSizeChange: false });
Expand Down

0 comments on commit 81fad01

Please sign in to comment.