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

Bug: TextInput with multiline and lineHeight has height issue when controlled #46207

Open
Unuuuuu opened this issue Aug 25, 2024 · 3 comments
Open
Labels
Component: TextInput Related to the TextInput component. Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Newer Patch Available

Comments

@Unuuuuu
Copy link

Unuuuuu commented Aug 25, 2024

Description

I'm experiencing a bug with the TextInput component when using it as a controlled component with both multiline and lineHeight properties. This issue occurs only on iOS; it does not occur on Android.

Expected Behavior:

The TextInput should adjust its height according to the content without any unexpected changes.

Actual Behavior:

On iOS, when the TextInput is controlled, the height of the TextInput increases unexpectedly as the number of lines increases.
This issue does not occur when the TextInput is uncontrolled.

Steps to reproduce

  1. Create a TextInput component with the following properties:
    • multiline={true}
    • lineHeight set to a specific value (e.g., 60)
    • Controlled by a state variable (value and onChangeText props).
  2. Type text into the TextInput to increase the number of lines.

React Native Version

0.75.2
I have confirmed that this issue does not occur in version 0.73.2.

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.4
  CPU: (8) arm64 Apple M1 Pro
  Memory: 236.09 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.12.2
    path: ~/.nvm/versions/node/v20.12.2/bin/node
  Yarn:
    version: 1.22.22
    path: ~/.nvm/versions/node/v20.12.2/bin/yarn
  npm:
    version: 10.5.0
    path: ~/.nvm/versions/node/v20.12.2/bin/npm
  Watchman:
    version: 2024.07.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK: Not Found
IDEs:
  Android Studio: 2024.1 AI-241.18034.62.2411.12071903
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.12
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react: Not Found
  react-native: Not Found
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: Not found
  newArchEnabled: Not found
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Stacktrace or Logs

-

Reproducer

https://snack.expo.dev/@holyunwoo/eager-indigo-cereal?platform=ios

Screenshots and Videos

Uncontrolled

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-08-25.at.18.18.07.mp4

Controlled

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-08-25.at.18.18.27.mp4
SCR-20240825-qgyj
@react-native-bot
Copy link
Collaborator

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.74.5. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@react-native-bot react-native-bot added the Component: TextInput Related to the TextInput component. label Aug 25, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - undefined. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@Unuuuuu
Copy link
Author

Unuuuuu commented Aug 27, 2024

This issue only occurs in the iOS simulator and does not occur when running on an actual device.

@cortinico cortinico added Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. and removed Needs: Triage 🔍 labels Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: TextInput Related to the TextInput component. Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Newer Patch Available
Projects
None yet
Development

No branches or pull requests

4 participants
@cortinico @react-native-bot @Unuuuuu and others