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

TextInput wrong onChange call after value set (multiline, ios) #34891

Closed
eyshella opened this issue Oct 7, 2022 · 5 comments
Closed

TextInput wrong onChange call after value set (multiline, ios) #34891

eyshella opened this issue Oct 7, 2022 · 5 comments
Labels
Component: TextInput Related to the TextInput component. Needs: Triage 🔍 Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@eyshella
Copy link

eyshella commented Oct 7, 2022

Description

TextInput component calls onChange callback with empty string right after blur method was called when backspace button was pressed few times on empty input. This can make it impossible to set value from outside in specific environment.
The issue reproducible only on iOS when multiline is set.
You can find more details in steps to reproduce.

Version

0.70.2

Output of npx react-native info

info Fetching system and libraries information...
System:
OS: macOS 12.6
CPU: (8) arm64 Apple M1
Memory: 106.98 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.17.0 - ~/.nvm/versions/node/v16.17.0/bin/node
Yarn: Not Found
npm: 8.15.0 - ~/.nvm/versions/node/v16.17.0/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
Android SDK: Not Found
IDEs:
Android Studio: 2021.3 AI-213.7172.25.2113.9014738
Xcode: 14.0/14A309 - /usr/bin/xcodebuild
Languages:
Java: javac 19 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.1.0 => 18.1.0
react-native: 0.70.2 => 0.70.2
react-native-macos: Not Found
npmGlobalPackages:
react-native: Not Found

Steps to reproduce

  1. Use iOS environment
  2. Add TextInput component with multiline set to true
  3. Add onChangeCallback callback and use it in TextInput onChange method (set event as an argument)
  4. Add inputRef reference and use it as TextInput ref
  5. Add a TouchableOpacity outside input
  6. Add onButtonPressCallback callback and use it in TouchableOpacity onPress method
  7. Add state value inputValue with setInputValue setter and use as TextInput value prop.
  8. Add the following to the onChangeCallback: setInputValue(event.nativeEvent.text)
  9. Add the following to the onButtonPressCallback: setInputValue("I am test string!") inputRef.current.blur()
  10. Run the project
  11. Focus input field and press backspace button on the keyboard few times
  12. Press the button (TouchableOpacity) without manual reseting focus from the input field
  13. As you see - input value hasn't been set.

Snack, code example, screenshot, or link to a repository

https://snack.expo.dev/@eyshella/textinput-multiline-weird-onchange

@bashen1
Copy link

bashen1 commented Feb 22, 2023

same issue

@Limoer96
Copy link

how to fix that?

@akarri2001
Copy link

This is late, but instead of using onChange, I switched it out for onChangeText and it worked

Copy link

github-actions bot commented Mar 6, 2024

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Mar 6, 2024
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 13, 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. Needs: Triage 🔍 Platform: iOS iOS applications. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants