Commit 916ba5e
Fix TextInput placeholder stuck on multiple lines
Summary:
On Android, when a `TextInput`'s `multiline` prop changes from `false` to `true` and back to `false`, the placeholder stayed rendered across multiple lines instead of returning to a single line.
`ReactEditText.setInputType` only forced the view out of single-line mode when `multiline` was enabled; it never restored single-line mode when `multiline` was disabled. `TextView.setInputType` re-applies its single-line layout (max lines, horizontal scrolling) only when its internal single-line flag actually changes, and because we toggle that flag off whenever multiline is on, it can be stale so the reset is skipped.
On top of that, under the new architecture the view is not re-measured when only the input type changes while the measured size is unchanged. The placeholder is then rebuilt at draw time at the view's physical width and stays wrapped.
This change restores single-line mode when `multiline` is turned off (skipping secure-text fields so their password transformation method is preserved) and forces a re-measure on the multiline-to-single-line transition, so the placeholder is laid out on a single line again.
Changelog:
[Android][Fixed] - Fix `TextInput` placeholder staying on multiple lines after `multiline` is toggled from `true` back to `false`
Reviewed By: javache
Differential Revision: D1083708691 parent 549e4e2 commit 916ba5e
1 file changed
Lines changed: 30 additions & 2 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/views/textinput
Lines changed: 30 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
143 | 144 | | |
144 | 145 | | |
145 | 146 | | |
| |||
544 | 545 | | |
545 | 546 | | |
546 | 547 | | |
547 | | - | |
548 | | - | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
549 | 552 | | |
550 | 553 | | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
551 | 562 | | |
552 | 563 | | |
553 | 564 | | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
554 | 581 | | |
| 582 | + | |
555 | 583 | | |
556 | 584 | | |
557 | 585 | | |
| |||
0 commit comments