[$175] Composer - Input field renders at two-line height before typing starts
If you haven’t already, check out our contributing guidelines for onboarding. To join our Slack channel, fill out this form.
Version Number: Reproducible in staging?: Needs Reproduction (Unable to reproduce) Reproducible in production?: Needs Reproduction If this was caught during regression testing, add the test name, ID and link from BrowserStack: Email or phone of affected tester (no customers): Logs: https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by: @AndrewGable Slack conversation (hyperlinked to channel name): #Expensify Bugs
Action Performed:
- Open a DM
- Look at the composer ("Write something...") before typing anything.
- Start typing a message.
Expected Result:
The composer should render at a single-line height by default
Actual Result:
The composer appears at a two-line height while empty/showing the placeholder
Workaround:
Unknwon
Platforms:
Select the officially supported platforms where the issue was reproduced:
- [ ] Android: App
- [ ] Android: mWeb Chrome
- [ ] iOS: App
- [ ] iOS: mWeb Safari
- [ ] iOS: mWeb Chrome
- [x] Windows: Chrome
- [x] MacOS: Chrome / Safari
Screenshots/Videos
Upwork Automation - Do Not Edit
- Upwork Job URL: https://www.upwork.com/jobs/~022108247042353130137
- Upwork Job ID: 2108247042353130137
- Last Price Increase: 2026-10-08
Issue Owner
Current Issue Owner: @situchan
Proposal
Reproduced on web. The bug happens when you send a restored draft without editing it, and the draft was one long line that wrapped to 2 lines:
- In a DM, type one long line that wraps to 2 lines. Do not use Enter or Shift+Enter.
- Leave the chat and come back, or reload, so the composer reloads with the draft.
- Send it without editing.
- The empty composer stays at 2-line height, with the placeholder at the top, until you type.
Sending a newly typed multi-line message does not trigger it. This explains why QA could not reproduce it.
What is the root cause of that problem?
The composer saves the first height it measures as the "empty" height. The guard only skips text that contains \n. See ComposerWithSuggestions.tsx:1007-1009.
When the composer loads with a long wrapped draft, its first measurement is 2 lines tall. That value is saved as the "empty" height, because the draft has no \n.
On send, resetHeight() fixes the composer at that saved 2-line height. The fixed height is only removed when onContentSizeChange fires (:1004) or when the user types (:689). The new height matches the last measured height, so no size change fires. The composer stays at 2 lines.
What changes do you think we should make in order to solve the problem?
In ComposerWithSuggestions.tsx:
- Save the empty height only when the input is actually empty (
valueRef.current === ''), not just when it has no\n. - Stop relying on
onContentSizeChangeto remove the fixed height. ClearcomposerHeightAfterClearon the next animation frame after it is set.
Part 2 alone fixes the stuck state. Part 1 stops the wrong value from being saved. Retest the cursor flash fixed in Fix cursor moves to write something briefly with expand compose box, which added this height-reset logic.
What alternative solutions did you explore? (Optional)
Compute the empty height from styles (line height plus vertical padding) instead of measuring it.
Reproduction screenshots (web, dev)
Restored 2-line draft before sending:

Empty composer still taller than one line, 3 seconds after sending:

Back to one line after typing one character:

The tester measured heights from screenshots. It could not read DOM values directly.
Other details
- Ruled out a whitespace-only draft. The placeholder only shows when the input is truly empty (
:empty::beforein react-native-live-markdown). - Possible second trigger (not verified): the composer is first measured while the window is narrow or a side panel is animating in.
- Allow editing messages in Composer on narrow screens V2 reworked this code and the
resetHeightcall inuseComposerSubmit.ts:178. No PR from August to October 2026 changed it.
Next Steps for Contributor+ team:
To accept: @MelvinBot implement [this](https://github.com/Expensify/App/issues/103497) to create a draft PR.
To refine: @MelvinBot <your feedback>
To reject: Explain why you are rejecting Melvin's proposal.
Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External)
Job added to Upwork: https://www.upwork.com/jobs/~022108247042353130137
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01b77415f16d156068
Proposal
Please re-state the problem that we are trying to solve in this issue.
In a chat or DM, the message composer renders at a two-line height while empty and showing the placeholder ("Write something..."), instead of rendering at a single-line height. The composer remains stuck at two lines until the user starts typing.
What is the root cause of that problem?
In src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions.tsx (lines 1007–1009):
// Store the default collapsed composer height, so we can later reset the height when we clear the input.
if (emptyComposerHeightRef.current === null && inputHeight > 0 && !valueRef.current.includes('\n')) {
emptyComposerHeightRef.current = inputHeight;
}
- The code attempts to measure and store the initial collapsed height of an empty composer into
emptyComposerHeightRef.current. However, it uses!valueRef.current.includes('\n')as the predicate. If a draft message was restored upon opening the report (or typed without explicit newlines) that wraps across 2 lines, its height exceeds a single line but contains no\n. Consequently,emptyComposerHeightRef.currentcaptures the 2-line wrapped height instead of the single-line baseline height. - When the user sends the draft message,
resetHeight()(lines 850–855) assignssetComposerHeightAfterClear(emptyComposerHeightRef.current), locking the empty composer to the erroneously stored 2-line height. clearComposerHeight()is only called insidehandleContentSizeChange. Because the empty input does not fire a subsequent content size change event after submission, the composer stays pinned to the 2-line height until the user types.
What changes do you think we should make in order to solve the problem?
In src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions.tsx:
-
Only record baseline height when input is truly empty: Update the condition in
handleContentSizeChangesoemptyComposerHeightRef.currentis only captured when the input contains no text:if (emptyComposerHeightRef.current === null && inputHeight > 0 && valueRef.current.trim() === '') { emptyComposerHeightRef.current = inputHeight; }This guarantees that long wrapped drafts or multi-line messages without newlines never poison
emptyComposerHeightRef.current. -
Auto-release temporary height lock after clear: In
resetHeight(), scheduleclearComposerHeight()viarequestAnimationFrameso the temporary height lock applied during submission prevents cursor flashing/jumping while immediately relinquishing fixed height back to flex layout:const resetHeight = useCallback(() => { if (!emptyComposerHeightRef.current) { return; } setComposerHeightAfterClear(emptyComposerHeightRef.current); requestAnimationFrame(() => { clearComposerHeight(); }); }, [clearComposerHeight]);
What alternative solutions did you explore? (Optional)
- Hardcoding line height constants: Calculating height statically using font size and vertical padding misses platform-specific font rendering metrics (Android vs iOS vs Web). Capturing the true measured height when
valueRef.current.trim() === ''preserves exact native measurement without hardcoding.
What specific scenarios should we cover in automated tests?
In tests/unit/ComposerWithSuggestionsTest.tsx:
- When
handleContentSizeChangefires with non-empty text lacking newlines (e.g. wrapped draft), verify thatemptyComposerHeightRef.currentis not set. - When
handleContentSizeChangefires with empty text (""), verify thatemptyComposerHeightRef.currentis recorded. - Verify that sending a multi-line or wrapped message resets the composer to the single-line height and releases the fixed height lock.
:warning: Unable to store contributor details
Details
Auth SetContributorDetails returned an error 401 Contributor details already exist
Proposal
Please re-state the problem that we are trying to solve in this issue.
The empty message composer can remain at a two-line height instead of collapsing back to the normal single-line height after a restored wrapped draft is sent.
What is the root cause of that problem?
The composer caches its "empty" height from the first measured content height using a condition that only excludes values containing a newline.
A restored draft can wrap onto two visual lines without containing \n. In that case the composer records that wrapped two-line measurement as emptyComposerHeightRef.current. When the draft is sent, resetHeight() restores that incorrect cached value, so the now-empty composer remains two lines tall until another content-size change or user input clears the fixed height.
What changes do you think we should make in order to solve the problem?
- Only record
emptyComposerHeightRef.currentwhen the composer value is actually empty, not merely newline-free. - Ensure the temporary fixed height used during clear/reset is released deterministically after the reset instead of depending only on a subsequent
onContentSizeChange. - Keep the existing anti-flicker behavior intact and add regression coverage for a restored long single-line draft that visually wraps, is sent without editing, and must return to the normal one-line empty composer height.
What alternative solutions did you explore? (Optional)
Hardcoding the single-line height would avoid the stale measurement but would be more fragile across platforms/font metrics. Reusing the measured empty state is safer as long as it is captured only from a truly empty composer.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~010e53044b5828fe60
Proposal
Please re-state the problem that we are trying to solve in this issue.
In a chat or DM, after sending a restored wrapped draft message, the empty composer remains stuck at a two-line height with the placeholder visible, instead of collapsing back down to a single-line height.
What is the root cause of that problem?
In src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions.tsx (lines 1006–1009):
// Store the default collapsed composer height, so we can later reset the height when we clear the input.
if (emptyComposerHeightRef.current === null && inputHeight > 0 && !valueRef.current.includes('\n')) {
emptyComposerHeightRef.current = inputHeight;
}
- The code attempts to cache the baseline empty collapsed composer height into
emptyComposerHeightRef.current. However, it guards with!valueRef.current.includes('\n'). - When a chat is opened with an existing restored draft that visually wraps onto 2 lines without containing an explicit newline (
\n), the firsthandleContentSizeChangemeasurement captures the 2-line wrapped height and erroneously stores it intoemptyComposerHeightRef.current. - When the user submits the draft without editing,
resetHeight()(lines 850–855) setscomposerHeightAfterCleartoemptyComposerHeightRef.current(2-line height). clearComposerHeight()is only triggered when a subsequenthandleContentSizeChangeoronChangeTextevent occurs. Because the input is now empty and no new text is being typed, no further content size changes fire, leaving the composer pinned to the 2-line height until the user starts typing.
What changes do you think we should make in order to solve the problem?
In src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions.tsx:
- Only record baseline collapsed height when the input is actually empty:
if (emptyComposerHeightRef.current === null && inputHeight > 0 && valueRef.current.trim() === '') {
emptyComposerHeightRef.current = inputHeight;
}
This guarantees that wrapped drafts without newlines will never contaminate emptyComposerHeightRef.current.
- Handle fallback and release height lock deterministically in
resetHeight():
const resetHeight = useCallback(() => {
if (!emptyComposerHeightRef.current) {
// If the composer mounted with an existing draft and emptyComposerHeightRef was never recorded,
// clear the manual height immediately to let natural flexbox layout collapse to 1 line
setComposerHeightAfterClear(null);
return;
}
setComposerHeightAfterClear(emptyComposerHeightRef.current);
requestAnimationFrame(() => {
clearComposerHeight();
});
}, [clearComposerHeight]);
Why this works:
- If the chat was opened empty,
emptyComposerHeightRef.currentcleanly records the true 1-line measured height. When submitting any multi-line or wrapped message,resetHeight()locks it to 1 line to prevent layout flashing, then releases it on the next paint frame viarequestAnimationFrame. - If the chat was opened with an existing draft (where
emptyComposerHeightRefwas never set),resetHeight()explicitly resetssetComposerHeightAfterClear(null), allowing the empty TextInput to naturally collapse to 1 line via flexbox with zero stuck height.
What alternative solutions did you explore? (Optional)
- Hardcoding line height constants: Calculating height statically using font size and padding misses platform-specific font metrics and OS font scaling (iOS Dynamic Type, Android font scaling). Measuring dynamically when
valueRef.current.trim() === ''with an unconstrained fallback is safer and cross-platform native.
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Proposal
Please re-state the problem that we are trying to solve in this issue.
The empty message composer renders stuck at a two-line height with the placeholder visible instead of collapsing back down to a single-line height after sending a draft.
What is the root cause of that problem?
In src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions.tsx:
- Lines 1010–1013:
if (emptyComposerHeightRef.current === null && inputHeight > 0 && !valueRef.current.includes('\n')) {
emptyComposerHeightRef.current = inputHeight;
}
The check uses !valueRef.current.includes('\n'). When a conversation opens with an existing saved draft that visually wraps onto 2 lines without explicit newline characters (\n), the initial handleContentSizeChange measures the 2-line wrapped height and incorrectly saves it as emptyComposerHeightRef.current.
2. When the user sends the draft, resetHeight() sets composerHeightAfterClear to emptyComposerHeightRef.current (which is poisoned with the 2-line measurement). Because the composer is now empty and no subsequent input events fire, clearComposerHeight() is never called, leaving the empty composer stuck at 2-line height.
What changes do you think we should make in order to solve the problem?
In src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions.tsx:
- Only record baseline collapsed height when the input is actually empty (
valueRef.current.trim() === ''):
if (emptyComposerHeightRef.current === null && inputHeight > 0 && valueRef.current.trim() === '') {
emptyComposerHeightRef.current = inputHeight;
}
- In
resetHeight(), ifemptyComposerHeightRef.currentwas not recorded (e.g., opened with an existing long draft), resetsetComposerHeightAfterClear(null)immediately to allow native flex layout to settle at single-line height. - Automatically release the temporary height lock via
requestAnimationFrame(() => clearComposerHeight())so layout flickering is prevented during message submission while ensuring the composer returns to natural single-line height.
Tested and pre-coded on branch fix/103497-composer-empty-height.
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0163955a2ba22190aa
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
Can't reproduce
Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External)
Triggered auto assignment to Contributor-plus team member for initial proposal review - @situchan (External)
Reassigning to someone else to see if they can reproduce it
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~0170d6b02e9440e604
Proposal
Please re-state the problem that we are trying to solve in this issue.
The empty message composer renders stuck at a two-line height with the placeholder visible before typing starts, instead of cleanly settling at single-line baseline height.
What is the root cause of that problem?
In src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions.tsx:1010-1013:
if (emptyComposerHeightRef.current === null && inputHeight > 0 && !valueRef.current.includes('\n')) {
emptyComposerHeightRef.current = inputHeight;
}
- The baseline empty height is checked with
!valueRef.current.includes('\n'). If the screen mounts with an existing saved draft that wraps across two lines without hard newline characters (\n),inputHeightmeasures the 2-line wrapped height and incorrectly locksemptyComposerHeightRef.currentto that 2-line dimension. - In
resetHeight(), the composer appliescomposerHeightAfterClearset toemptyComposerHeightRef.current. Because the input is now empty and placeholder text is displayed,emptyComposerHeightRef.currentkeeps the container pinned at 2-line height until manual typing occurs.
What changes do you think we should make in order to solve the problem?
In src/pages/inbox/report/ReportActionCompose/ComposerWithSuggestions.tsx:
- Only record baseline empty height when the input is strictly empty:
if (emptyComposerHeightRef.current === null && inputHeight > 0 && valueRef.current.trim() === '') {
emptyComposerHeightRef.current = inputHeight;
}
- In
resetHeight(), ensure safe fallback ifemptyComposerHeightRef.currentwas never set during a draft mount, clearing the height immediately viasetComposerHeightAfterClear(null). - Release the height lock cleanly on the next animation frame using
requestAnimationFrame(() => clearComposerHeight())to avoid layout flashes during send while allowing the composer to return to native single-line height.
What alternative solutions did you explore? (Optional)
Hardcoding line-height values: This fails across platforms due to distinct font rendering metrics and OS accessibility text scaling (Dynamic Type on iOS / Font Scale on Android). Dynamically evaluating valueRef.current.trim() === '' preserves native responsiveness.
✅ Contributor details stored successfully. Thank you for contributing to Expensify!
@situchan Whoops! This issue is 2 days overdue. Let's get this updated quick!
Reproduced on web (local dev build of main @ abff087, Windows 11, Chrome).
- Open any chat. Type one long line that wraps to 2 lines. Don't press Enter or Shift+Enter.
- Switch to another chat in the LHN, then switch back. The draft is restored.
- Send the draft without editing it.
- The empty composer stays at the 2-line height with the placeholder at the top. It measured 56px with an inline
height: 56px, against 36px normally. It stayed that way for over 10 seconds and only went back to normal after I typed a character.
Two details that may explain why it's hard to reproduce:
- The return has to be in-app navigation. Coming back with a browser reload did not reproduce it for me. After a reload the composer resets to 36px after sending.
- Once it happens, every later send in that chat also leaves the composer at 2 lines, even for freshly typed messages, until the composer remounts. On a fresh load, a freshly typed wrapped message resets correctly.
Both match emptyComposerHeightRef in ComposerWithSuggestions.tsx (L1009-1010). It is set once per mount, from the first measured height of text with no \n, so a restored wrapped draft saves the 2-line height as the "empty" height.
Before / after:
📣 @mukesh-dev-git! 📣 Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork. Please follow these steps:
- Make sure you've read and understood the contributing guidelines.
- Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
- Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
- Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
Contributor details Your Expensify account email: [email protected] Upwork Profile Link: https://www.upwork.com/freelancers/~01dfce06964443a120