-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
ios on selectionChange does not work with multiline set to true #30298
Comments
I put single-line: onChange -> onSelectionChangemulti-line: onSelectionChange -> onChangeNot sure but it seems like a bug because of this comment, it says:
|
Do you know of a way to get selection from either ref or native props? I know we can use setNativeProps, but am looking for a way to getSelection |
@VivekNeel For me I'll just use <TextInput
onChangeText={handleChange}
value={value}
multiline
// selection={selection} <----- remove this
onSelectionChange={handleSelection}
placeholder="Enter a text"
style={{marginTop: 100, marginHorizontal: 16}} /> |
I'm experiencing this exact issue too, however I need the the Generally if I am not dictating the selection I can set it to this.setState({ selection: undefined })
<TextInput
selection={this.state.selection}
...
/> but when I do need to set the selection (I am highlighting an entire word in some cases whenever the cursor position lands within the word), the behavior is as described above, where the order those are called resets the cursor position to 0. I've yet to find a good workaround for this yet |
actually for now, I've found that using |
This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
Damn this problem still exists in 2023. My cursor keeps moving to the first position when selection is used. Fortunately setNativeProps can be used to force the cursor to go wherever i want it to. |
This issue deserves some love 💔 |
This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for 7 days with no activity. |
This looks like it was never fixed, but I just want to add that I can't reproduce this on version 0.73.x new arch |
Description
I have a basic text input with multiline set to true. Additionally it has
selection
andonSelectionChange
props set which causes cursor to move to initial position whenever there is change inonChangeText
.Here it's the video : https://streamable.com/bchsz4
Here it's the repro : https://github.com/VivekNeel/IOS_SELECTION_CHANGE
Here it's the sample code :
React Native version:
Steps To Reproduce
Expected Results
when typing in a text input using selection , onSelectionChange and multilne, cursor position should not get reset
Snack, code example, screenshot, or link to a repository:
https://github.com/VivekNeel/IOS_SELECTION_CHANGE
https://stackoverflow.com/questions/64639411/ios-react-native-onselectionchange-moves-cursor-to-initial-position-when-multlin
The text was updated successfully, but these errors were encountered: