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

TextInput - selection prop is not set on component creation #44398

Closed
wants to merge 1 commit into from

Conversation

alanleedev
Copy link
Contributor

Summary:
Problem:
selection prop is not being set on component creation.
Not quite sure which RN version this issue was introduced but fixing it on latest code.

Use playground for testing (refer to following diff)

Proposed Solution:

Added notes in comments but viewCommands.setTextAndSelection() is called only on text or selection update which relies on comparing data with lastNativeSelection. Problem is that lastNativeSelection is initially set to the props value that is passed in so does not send the command on component creation.

So assign a default selection value of {start: -1, end: -1} so it can be set on component creation.

Changelog:
[General][Fixed] - 'selectionprop inTextInput` was not being applied at component creation

Differential Revision: D56911712

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label May 2, 2024
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D56911712

Summary:
**Problem:**
`selection` prop is not being set on component creation.
Not quite sure which RN version this issue was introduced but fixing it on latest code.

Use playground for testing (refer to following diff)

**Proposed Solution:**

Added notes in comments but `viewCommands.setTextAndSelection()` is called only on text or selection update which relies on comparing data with `lastNativeSelection`. Problem is that `lastNativeSelection` is initially set to the props value that is passed in so does not send the command on component creation.

So assign a default selection value of `{start: -1, end: -1}` so it can be set on component creation.


**Changelog:**
[General][Fixed] - `selection` prop in `TextInput` was not being applied at component creation

Differential Revision: D56911712
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D56911712

@alanleedev
Copy link
Contributor Author

This PR fixes issue reported here: #44171

@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label May 7, 2024
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in be09d12.

Copy link

github-actions bot commented May 7, 2024

This pull request was successfully merged by @alanleedev in be09d12.

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants