-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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 cursor jump to right end when the input is empty (Android only) #28794
Comments
This might also relate to #28936, and how it affects only some devices |
This comment has been minimized.
This comment has been minimized.
What about how it affects webview's? For me, users are having issues with a react native scripted website through the webview. @fabriziobertoglio1987 |
This comment has been minimized.
This comment has been minimized.
@fabriziobertoglio1987 thanks for taking a look at this! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
possible solution inside @ReactProp(name = "placeholder")
public void setPlaceholder(ReactEditText view, @Nullable String placeholder) {
String text = placeholder == null ? "" : placeholder;
view.setHint(text);
} the problems seems to be connected to the use of the
react-native/flow/Stringish.js Line 14 in 5cde6c5
Probably value of The issue is caused by the useage of Maybe Types like Seems like the one above is the easiest solution to implement as there are other logic built on top of this |
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions. |
I believe it still requires attention. @fabriziobertoglio1987 has this PR that seems to fix the problem. It as a small 2 liner, but for some reason it was not merged yet. So if anyone could take a look at that it would be super cool. |
I'm facing the same issue and it's quite annoying, please help to verify and merge @fabriziobertoglio1987 's PR :( |
facing the same issue, my phone model is Realme 6 pro |
Hi @fabriziobertoglio1987, if I wanna try your solution, all I need to do is change the logic in the But after I add the changes
And run npx react-native run-android, the issue isn't resolved, could you please help me to clarify this |
@nenjamin2405 bro did you find a Solution |
This comment has been minimized.
This comment has been minimized.
still actual |
What is the solution for this issue? |
facing the same problem. any solution? |
Not sure why, but, setting multiline={true} fixed it for me
|
I also have this problem. TextInput cursor jump to right end when the input is empty with borderColor/borderWidth or backgroundColor set on parent View. but every thing is ok without placeholder. 1."react-native": "0.63.0" const Demo: React.FC<any> = () => {
const [value, setValue] = useState<string>()
return (
<SafeAreaView>
<View style={{ backgroundColor: 'red' }}>
<TextInput
value={value}
placeholder="placeholder"
textAlign="center"
onChangeText={v => {
setValue(v)
}}
></TextInput>
</View>
</SafeAreaView>
)
} |
This issue is still a thing. |
Also having this issue. Same as Antoine said, it works before adding text, then if text is added and removed, it jumps to the right. |
This worked for me |
Please provide all the information requested. Issues that do not follow this format are likely to stall.
Description
TextInput that has the
placeholder
set, and styles withtextAlign: "center"
and manages the value withuseState
hook, makes the cursor jump to the end of the input field when we clear the contents with backspace.Related StackOverflow question: https://stackoverflow.com/questions/60276121/textinput-cursor-jump-to-right-end-when-the-input-is-empty
React Native version:
Run
react-native info
in your terminal and copy the results here.System:
OS: macOS Mojave 10.14.6
CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
Memory: 39.64 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 8.11.4 - ~/.nvm/versions/node/v8.11.4/bin/node
Yarn: 1.9.4 - /usr/local/bin/yarn
npm: 6.14.1 - ~/.nvm/versions/node/v8.11.4/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.9.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 13.1, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play
Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 3.5 AI-191.8026.42.35.6010548
Xcode: 11.1/11A1027 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_241 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: ~16.9.0 => 16.9.0
react-native: ~0.62 => 0.62.2
npmGlobalPackages:
react-native: Not Found
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
App.tsx
fileSome times, when listening to changes in dev mode to update the app, the faulty behaviour is not noticed at first. When that happens, I comment out the
placeholder
prop and save for the app on my android emulator to refresh. Then I uncomment it again, and save to refresh one more time. With this I am able to reproduce the problem 100% of the time.Expected Results
When the style
textAlign: "center"
is set, the cursor should stay in the center after you clear the input.Snack, code example, screenshot, or link to a repository:
Please select the Android platform on snack to see the problem
https://snack.expo.io/QuGin01cF
The text was updated successfully, but these errors were encountered: