TextInput wrong onChange call after value set (multiline, ios) #34891
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.
Description
TextInput
component calls onChange callback with empty string right afterblur
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
whenmultiline
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
TextInput
component withmultiline
set totrue
onChangeCallback
callback and use it inTextInput
onChange
method (setevent
as an argument)inputRef
reference and use it asTextInput
refTouchableOpacity
outside inputonButtonPressCallback
callback and use it inTouchableOpacity
onPress
methodinputValue
withsetInputValue
setter and use asTextInput
value
prop.onChangeCallback
:setInputValue(event.nativeEvent.text)
onButtonPressCallback
:setInputValue("I am test string!") inputRef.current.blur()
TouchableOpacity
) without manual reseting focus from the input fieldSnack, code example, screenshot, or link to a repository
https://snack.expo.dev/@eyshella/textinput-multiline-weird-onchange
The text was updated successfully, but these errors were encountered: