-
Notifications
You must be signed in to change notification settings - Fork 24.6k
fix(ios): avoid incorrectly updating caret position #50680
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
Conversation
Hi @ouchuan! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at [email protected]. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
@cipolleschi hello, This PR is trying to fix #50680, can you take a look? |
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.
@ouchuan thanks for the fix. The code makes sense to me.
@cipolleschi has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
@cipolleschi merged this pull request in 7771317. |
This pull request was successfully merged by @ouchuan in 7771317 When will my fix make it into a release? | How to file a pick request? |
Summary: Avoid incorrectly updating caret position Pull Request resolved: #50641 The caret position is updated incorrectly when a user is first typing if an zero-length selection is set. [IOS] [CHANGED] - Typing into TextInput now will not cause the caret position to update to the beginning when a zero-length selection is set. Pull Request resolved: #50680 Test Plan: Tested with the following code(a simplified version from the code in #50641) ```js const [selection, setSelection] = useState({start: -1, end: -1}); const onSelectionChange = ( evt: NativeSyntheticEvent<TextInputSelectionChangeEventData>, ) => { const {selection} = evt.nativeEvent; const {start, end} = selection; console.log('selection change: ', start, end); setSelection(selection); }; return ( <View style={{ position: 'absolute', top: 50, left: 30 }}> <TextInput placeholder="test" selection={selection} onSelectionChange={onSelectionChange} /> </View> ); ``` When using the main branch, the caret position will jump back to the beginning after the first typing. It works fine after applying this commit. Reviewed By: fabriziocucci Differential Revision: D72957245 Pulled By: cipolleschi fbshipit-source-id: 3586797332b35e86b17f386a35e7d192ff758f7e
This pull request was successfully merged by @ouchuan in 89f4dd2 When will my fix make it into a release? | How to file a pick request? |
Avoid incorrectly updating caret position
Summary:
Pull Request resolved: #50641
The caret position is updated incorrectly when a user is first typing if an zero-length selection is set.
Changelog:
[IOS] [CHANGED] - Typing into TextInput now will not cause the caret position to update to the beginning when a zero-length selection is set.
Test Plan
Tested with the following code(a simplified version from the code in #50641)
When using the main branch, the caret position will jump back to the beginning after the first typing.
It works fine after applying this commit.