Skip to content

【iOS】The contentOffset property is missing from TextInputView's onScroll callback #43428

Description

@rabbitmouse

Description

I found that in the onScroll callback of textInput, the old schema contained the contentOffset attribute, but the new schema did not, causing a crash!

Steps to reproduce

const onInputScroll = (e) => {
    if (Platform.OS !== "web") {
      const {
        nativeEvent: {
          contentOffset: { x, y },
        },
      } = e;
      console.log('onInputScroll ====', e?.nativeEvent)
    }
  };

<TextInput
        onScroll={onInputScroll}
        ref={inputRef}
        multiline
>

React Native Version

0.73.3

Affected Platforms

Runtime - iOS

Areas

Fabric - The New Renderer

Output of npx react-native info

OS: macOS 14.1
  CPU: (8) arm64 Apple M1 Pro
  Memory: 109.81 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.6.1
    path: ~/.nvm/versions/node/v21.6.1/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.2.4
    path: ~/.nvm/versions/node/v21.6.1/bin/npm
  Watchman:
    version: 2023.09.18.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /Users/zhuzhiqin/.rvm/gems/ruby-2.7.2/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11330709
  Xcode:
    version: 15.0.1/15A507
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.10
    path: /usr/bin/javac
  Ruby:
    version: 2.7.2
    path: /Users/zhuzhiqin/.rvm/rubies/ruby-2.7.2/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native:
    installed: 0.73.3
    wanted: 0.73.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: true
  newArchEnabled: true

Stacktrace or Logs

Cannot read x from undefined

Reproducer

https://github.com/rabbitmouse

Screenshots and Videos

The old architecture scroll callback is as shown below
image

The new architecture scroll callback is as shown below
image

I confirm that this is still described in the official documentation.
image

Please fix it as soon as possible!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: TextInputRelated to the TextInput component.Platform: iOSiOS applications.Resolution: PR SubmittedA pull request with a fix has been provided.Type: New ArchitectureIssues and PRs related to new architecture (Fabric/Turbo Modules)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions