Fix TextInput placeholder stuck on multiple lines#57191
Closed
Abbondanzo wants to merge 1 commit into
Closed
Conversation
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: D108370869
|
@Abbondanzo has exported this pull request. If you are a Meta employee, you can view the originating Diff in D108370869. |
|
This pull request has been merged in df6de4f. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
On Android, when a
TextInput'smultilineprop changes fromfalsetotrueand back tofalse, the placeholder stayed rendered across multiple lines instead of returning to a single line.ReactEditText.setInputTypeonly forced the view out of single-line mode whenmultilinewas enabled; it never restored single-line mode whenmultilinewas disabled.TextView.setInputTypere-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
multilineis 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
TextInputplaceholder staying on multiple lines aftermultilineis toggled fromtrueback tofalseReviewed By: javache
Differential Revision: D108370869