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

Mobile: Fixes #11820: Fix cursor moves to incorrect position when revising TextInput value #11821

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const SettingComponent: React.FunctionComponent<Props> = props => {
autoCapitalize="none"
key="control"
style={styleSheet.settingControl}
value={props.value}
defaultValue={props.value}
Copy link
Owner

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.

Copy link
Contributor Author

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

onChangeText={(newValue: string) => void props.updateSettingValue(props.settingId, newValue)}
secureTextEntry={!!md.secure}
aria-labelledby={labelId}
Expand Down
Loading