-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Mobile: Fixes #11820: Fix cursor moves to incorrect position when revising TextInput value #11821
base: dev
Are you sure you want to change the base?
Conversation
@@ -149,7 +149,7 @@ const SettingComponent: React.FunctionComponent<Props> = props => { | |||
autoCapitalize="none" | |||
key="control" | |||
style={styleSheet.settingControl} | |||
value={props.value} | |||
defaultValue={props.value} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That may fix the issue but that doesn't seem correct? This is a controlled component so we shouldn't touch the defaultValue
property, only the value
and change
ones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there is another way to fix this unfortunately, other than to find a TextInput alternative in a third party library. I haven't been able to find an upstream report for this issue specifically on the react-native repository, but I'm pretty sure this is an upstream issue.
Speaking of controlled components, there is this issue on the react-native repository: facebook/react-native#34437 . It's an open issue since 2022 that controlling a TextInput component doesn't actually work, and the suggestion there is to make it uncontrolled by using defaultValue
I have now managed to find an alternative fix which respects the controlled nature of the component.
|
There is an issue on mobile whereby making amendments to text in React Native TextInput components causes the cursor to move before the new character which has just been typed, when the cursor is not currently at the end of the string. A similar issue has been raised here callstack/react-native-paper#1668 . I have managed to fix this behaviour by implementing the following 2 things:
This PR fixes #11820
Existing behaviour:
https://github.com/user-attachments/assets/c296269c-1ba5-492e-a00f-9a0b1e30e576
New behaviour with code change:
https://github.com/user-attachments/assets/559d9155-b526-4da7-92c4-448c06d0f0b8
Testing:
I have verified that amending and saving the value of a STRING type configuration setting (eg. WebDAV sync target settings / proxy url setting) updates and saves as expected