[Text-Input][Android][Fix]-fixes scroll on first render of textinput with default Value
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
After
cc @javache @NickGerleman
| 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: 14a72029836ee42ce919112973afab87164bc6e9 Branch: main
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.
This PR was closed because it has been stalled for 7 days with no activity.
@Abbondanzo could you see if this is valuable? and may be reopen it.
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
will fix the lint failure, thanks for re-opening and checking it out!
@Abbondanzo has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.
@Abbondanzo let me know where the internal Linter tests failed.
thanks @Abbondanzo for the review, yeah let me have a look at the same, to not have isFirstRender in the public api!
friendly ping @Abbondanzo
@Biki-das were you able to find a way around adding isFirstRender to the public API?
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.
This PR was closed because it has been stalled for 7 days with no activity.