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

[Text-Input][Android][Fix]-fixes scroll on first render of textinput with default Value #43480

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Biki-das
Copy link
Contributor

@Biki-das Biki-das commented Mar 14, 2024

Reopen #43342
Closed due to mess up with the forked branch!

Summary:

On rendering The TextInput with defaultValue at a case when the text string is longer than the screen size , a weird behaviour follows on android, where the leftmost text characters gets cut off and hidden, the reason is the cursor which moves to the end.

The cause of the same to my understanding is how the text is getting updated inside the ReactEditText. it has a range which it replaces with the text provided, if the cursor is in close proximity , the same is moved to the end for the replaced text.

the solution that i used is pretty straightforward, we need to make sure our cursor's position should be at the start of the text for the first render, we can just simply use the setText() method from the EditText, while we create the editText for the first time in the render cycle.
I have introduced a flag variable of isFirstRender initialised to true, this would allow us to call the EditText method and then eventually toggling it to false.

Changelog:

[ANDROID] [Fixed] - Fixes The Position of cursor on Overflowing Text on Android Text Input

Test Plan:

All Test Passing
Checked on RN TESTER
Long Text Behaviour section has been added to demonstrate the same

Before
Screenshot_1737139559

After
Screenshot_1737139374

@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 Mar 14, 2024
@Biki-das Biki-das changed the title [Text-Input][Fix]-fixes scroll on first render of textinput with default Value [Text-Input][Android][Fix]-fixes scroll on first render of textinput with default Value Mar 14, 2024
@Biki-das
Copy link
Contributor Author

Biki-das commented Mar 14, 2024

cc @javache @NickGerleman

@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Mar 14, 2024
@analysis-bot
Copy link

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 18,127,401 +65
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 21,493,975 +86
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 14a7202
Branch: main

@react-native-bot
Copy link
Collaborator

This PR 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.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Sep 17, 2024
@react-native-bot
Copy link
Collaborator

This PR was closed because it has been stalled for 7 days with no activity.

@Biki-das
Copy link
Contributor Author

@Abbondanzo could you see if this is valuable? and may be reopen it.

@facebook-github-bot
Copy link
Contributor

@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@Biki-das
Copy link
Contributor Author

Biki-das commented Jan 17, 2025

will fix the lint failure, thanks for re-opening and checking it out!

@facebook-github-bot
Copy link
Contributor

@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@Biki-das
Copy link
Contributor Author

@Abbondanzo let me know where the internal Linter tests failed.

@react-native-bot react-native-bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 18, 2025
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants