Repository navigation
Match the autoGrowHeight measurement text's line breaking to the input on Android - #102149
Conversation
The container height came from the hidden measurement element in TextInputMeasurement. On Android that element and the real input are laid out by different native text engines, so they disagree about where the value wraps and the box stays a line shorter than the visible input. Use the input's own onContentSizeChange as the height on native, cap the input with maxHeight instead of pinning it so Android keeps laying it out, and give the measurement element the same textBreakStrategy the input uses. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
The autoGrowContentHeight assignment fits within the 190 character print width, so oxfmt collapses it onto a single line. Commit that formatting so the Oxfmt check no longer reports a diff. Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Fixed and pushed — Cause:
The only remaining red check is Verification
CI on Still outstanding from the PR description, and unrelated to the checks: the Android wrap behaviour in this PR has not been observed on a device, since this environment is web-only. That still needs the emulator repro from Android - Report - Report title box is not automatically expanded with new line of text. before this moves forward. |
|
🤖 Web test steps verification results: ✅ pass On dev NewDot web the report title autoGrowHeight input grows at the exact keystroke that causes the text to wrap: it went to two lines on the 50th character and to three lines on the 98th, with every wrapped line fully visible in the same frame — no lag and no pinned-height regression. The build under test does include this PR's changes, and the web path is untouched by design since only the native implementation consumes the new content-size sizing.
Console errors: browser log capture is not part of the web agent-device surface, so none were collected. That means the page was not proven clean, not that it was verified error-free. No error UI appeared during the run. This is a web regression check. The fix itself is native-only, so it is the Android run that validates the actual bug. |
|
@MelvinBot pull main |
…xAutoGrow Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
@codex review |
|
@MelvinBot review |
|
The failing Analysis: Two tests in Evidence: The same two tests fail with the same error on other, unrelated PRs from the last hour:
This failure needs a fix on |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 27beb0d65f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| // The hidden element in TextInputMeasurement and the real input are laid out by two different native text engines, | ||
| // so they don't always agree on where the value wraps, which leaves the container a line short of the visible input. | ||
| // The input's own content size is the height it actually needs, so prefer it once it has reported one. | ||
| const autoGrowContentHeight = shouldUseAutoGrowHeight && inputContentHeight > 0 ? inputContentHeight + variables.inputPaddingTop + variables.inputPaddingBottom : textInputHeight; |
There was a problem hiding this comment.
Preserve multiline placeholder height
When an autoGrowHeight input is empty and its placeholder wraps to multiple lines, the first native onContentSizeChange replaces the hidden measurement with the empty input's one-line content height. That discards the placeholder sizing that TextInputMeasurement deliberately uses when value is empty, so the wrapper shrinks after mount and clips the multiline placeholder. Keep the measurement as the height source while there is no input value, or incorporate the placeholder's measured height.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not valid.
iOS: the premise is wrong. RN makes the placeholder a floor on the reported content size, RCTUITextView.mm:296-304:
- (CGSize)contentSize
{
CGSize contentSize = super.contentSize;
CGSize placeholderSize = _placeholderView.isHidden ? CGSizeZero : self.placeholderSize;
// When a text input is empty, it actually displays a placeholder.
// So, we have to consider `placeholderSize` as a minimum `contentSize`.
return CGSizeMake(MAX(contentSize.width, placeholderSize.width), MAX(contentSize.height, placeholderSize.height));
}placeholderSize is measured with numberOfLines = 0 and a boundingRectWithSize wrap, so a multi-line placeholder is already reported at its full wrapped height. Nothing gets discarded.
It does hold on Android, where ReactTextContentSizeWatcher reads editText.layout (the text layout, not mHintLayout), so an empty input reports one line however the hint wraps.
But no call site can reach it. No non-markdown autoGrowHeight input passes placeholder. Every affected screen (RejectExpenseReportPage, EditReportFieldText, CloseAccountPage, DynamicExitSurveyReasonPage, ReportsDefaultTitle, SamlConfigurationDetailsSectionContent) passes label only, with no prefix/suffix and no forceActiveLabel. DynamicExitSurveyReasonPage:143 looks like a hit but that is the translation key exitSurvey.responsePlaceholder passed as label. The one real pairing in the repo is TextInput.stories.tsx:144, Storybook, which renders on web where shouldSizeToContent is false.
With placeholder undefined the clone renders nothing, so its height is just the 23px of padding: clamp(31, 52, 115) = 52, identical to the PR's 20 + 23 + 8 -> clamp(51, 52, 115) = 52. No difference from main on either platform.
A third gate is also missed: even with a placeholder passed, the input only renders one when isFocused || !hasLabel || forceActiveLabel || prefixCharacter || suffixCharacter (index.native.tsx:294), while the clone measures the raw placeholder unconditionally. So a labeled, unfocused input already over-sizes its container on main. Pre-existing, unrelated to this PR.
It is a narrow special case of the real root cause: the inputContentHeight > 0 guard discarding the clone outright. Fixing that with Math.max(textInputHeight, inputContentHeight + verticalPadding) covers this for free if a placeholder is ever added to one of these screens.
ReviewThe approach looks right to me. Using the input's own
What I checked
|
|
Both failing checks come from
The fixes belong on |
|
Nothing has changed since my last check. Both failing checks still come from
No fix for either has merged to |
|
@MelvinBot address #102149 (comment). Also simplify all inline comments |
|
Nothing has changed since my last check. Both failing checks still come from
The latest commit on |
|
The failing checks still come from
After fixes for both land on Your request to address my review and simplify the inline comments got a check-status reply by mistake. No code changed. To have me make those changes, send that request again. |
|
@MelvinBot address #102149 (comment). Also simplify all inline comments |
…nge, and simplify comments Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
I addressed the review in a219a9a and simplified all the code comments this PR adds.
Lint, typecheck, spell check, and |
|
@MelvinBot |
|
This request is already done. I addressed the review and simplified the inline comments in a219a9a. See my earlier reply for details. No new changes were needed. |
|
@mkhutornyi Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cd63f67836
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
No. Nothing in App passes DetailsOn
Each wrapper spreads |
|
We've got test and lint failures |
|
@MelvinBot pull main |
…xAutoGrow Co-authored-by: mkhutornyi <mkhutornyi@users.noreply.github.com>
|
Merged the latest |
|
@mkhutornyi @chuckdries One of you needs to copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
🚧 chuckdries has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/chuckdries in version: 9.5.0-0 🚀
|
|
No help site update is needed. This PR fixes an Android bug so multi-line inputs grow as you type, which users already expect, and no help article sentence becomes incorrect. |
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.5.0-5 🚀
Bundle Size Analysis (Sentry): |
























Explanation of Change
The height of an
autoGrowHeightinput comes from a hidden, off-screen<Text>copy of the value inTextInputMeasurement. The container uses that copy's measured height.On Android, React Native's
<Text>uses thehighQualityline breaker by default, butRNTextInputsetstextBreakStrategy="simple". The hidden copy and the visible input therefore wrap words at different points. The input gains a line first, while the copy still reports the old line count. The box stays a line short until enough characters are typed for the copy to wrap too. Because wrapping is word-by-word, the box seems to grow only once the text reaches the middle of the new line.This change sets
textBreakStrategy="simple"on both hidden measurement<Text>elements, so they break lines the same way as the input. The prop only affects Android.This is not a regression from #97489. That PR only turned on this measurement path for the report title, where the lag became visible. The measurement path itself is old, which is why the bug also reproduces in production.
Fixed Issues
$ #99718
PROPOSAL: #99718 (comment)
Tests
Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)Avatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.