react-native icon indicating copy to clipboard operation
react-native copied to clipboard

TextInput - `selection` prop is not set on component creation

Open alanleedev opened this issue 10 months ago • 3 comments

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

alanleedev avatar May 02 '24 23:05 alanleedev

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

facebook-github-bot avatar May 02 '24 23:05 facebook-github-bot

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

facebook-github-bot avatar May 03 '24 02:05 facebook-github-bot

This PR fixes issue reported here: https://github.com/facebook/react-native/issues/44171

alanleedev avatar May 03 '24 03:05 alanleedev

This pull request has been merged in facebook/react-native@be09d12667044f237f08af410b2838062eb8e657.

facebook-github-bot avatar May 07 '24 20:05 facebook-github-bot

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

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

github-actions[bot] avatar May 07 '24 20:05 github-actions[bot]