-
Notifications
You must be signed in to change notification settings - Fork 24.6k
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
Can't prevent default input in TextInput in controlled component #38155
Comments
|
I'm using Expo. I'm not sure how to update react-native. Got an error when I do:
|
Can you try on a non-Expo project and verify that the issue is happening also there? |
Sure will try to create a demo, but it may take a while since I never used raw react-native. |
I can confirm the same happen in React-Native without expo, tested on 0.72.1
|
Can you also share a repro? |
|
Sure, it's the default app created with react-native with the component in the original post. But here is it: https://github.com/jcubic/react-native-bug |
Hi @jcubic, & @cortinico, this looks like a good first contribution, can I pick this up, and debug more? |
Please do 🙏 |
Any tips on where I should look in the code? |
Hi! The The conditions excel and I took a look around the native It seems that there is a condition on the
And we might have to add in a similar Boolean condition for a Again, this is something from the perspective of a beginner community contributor, I could be wrong. |
@vision72 did you try to make your change and test locally if it works? Experimentation is the best way to test if you're right. Now I have more free time and I will also try to debug this, unless you will solve this first. |
same issue, have any update? |
1 similar comment
same issue, have any update? |
Description
The comment in #24585 suggested creating another issue for this. It's also similar to #23578.
The problem is that you can't prevent the default behavior of controlled TextInput in ReactNative.
I've asked this on StackOverflow: How to prevent adding typed keys into controlled TextInput in React-Native?. But looking at similar issues this is a bug (or missing feature) in ReactNative.
React Native Version
0.71.8
Output of
npx react-native info
info Fetching system and libraries information...
System:
OS: Linux 5.19 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
Memory: 19.22 GB / 30.98 GB
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 20.3.0 - ~/.nvm/versions/node/v20.3.0/bin/node
Yarn: 1.22.19 - ~/.nvm/versions/node/v20.3.0/bin/yarn
npm: 9.6.7 - ~/.nvm/versions/node/v20.3.0/bin/npm
Watchman: Not Found
SDKs:
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Languages:
Java: 1.8.0_362 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.71.8 => 0.71.8
npmGlobalPackages:
react-native: Not Found
info React Native v0.72.1 is now available (your project is running on v0.71.8).
info Changelog: https://github.com/facebook/react-native/releases/tag/v0.72.1
info Diff: https://react-native-community.github.io/upgrade-helper/?from=0.71.8
info For more info, check out "https://reactnative.dev/docs/upgrading".
Steps to reproduce
Type the number into the input field with the code below. The code works on the Expo playground but fails on Android Emulator (didn't tested on a real device).
From the demo I expect the input to not change.
Snack, code example, screenshot, or link to a repository
event.preventDefault() also doesn't work:
The text was updated successfully, but these errors were encountered: