Skip to content

[$175] Composer - Input field renders at two-line height before typing starts #103497

Closed

Description

@m-natarajan

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:

  1. Open a DM
  2. Look at the composer ("Write something...") before typing anything.
  3. 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
  • Windows: Chrome
  • MacOS: Chrome / Safari

Screenshots/Videos

Image

View all open jobs on GitHub

Upwork Automation - Do Not Edit
Issue OwnerCurrent Issue Owner: @situchan

Activity

  1. added
    BugSomething is broken. Auto assigns a BugZero manager.
    on Oct 8, 2026
  2. MelvinBot commented on Oct 8, 2026

    @MelvinBot
    Contributor

    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:

    1. In a DM, type one long line that wraps to 2 lines. Do not use Enter or Shift+Enter.
    2. Leave the chat and come back, or reload, so the composer reloads with the draft.
    3. Send it without editing.
    4. 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:

    1. Save the empty height only when the input is actually empty (valueRef.current === ''), not just when it has no \n.
    2. Stop relying on onContentSizeChange to remove the fixed height. Clear composerHeightAfterClear on 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:

    Composer reopened with a restored draft that wraps to 2 lines

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

    Empty composer still taller than one line 3s after sending

    Back to one line after typing one character:

    Composer back to one line after typing a 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::before in 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 resetHeight call in useComposerSubmit.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.


    view run · view recording

  3. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Oct 8, 2026
  4. melvin-bot commented on Oct 8, 2026

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @DylanDylann (External)

  5. changed the title [-]Composer - Input field renders at two-line height before typing starts[/-] [+][$175] Composer - Input field renders at two-line height before typing starts[/+] on Oct 8, 2026
  6. melvin-bot commented on Oct 8, 2026

    @melvin-bot
  7. RajGahoi commented on Oct 8, 2026

    @RajGahoi

    Contributor details
    Your Expensify account email: gahoiraj01@gmail.com
    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;
    }
    1. 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.current captures the 2-line wrapped height instead of the single-line baseline height.
    2. When the user sends the draft message, resetHeight() (lines 850–855) assigns setComposerHeightAfterClear(emptyComposerHeightRef.current), locking the empty composer to the erroneously stored 2-line height.
    3. clearComposerHeight() is only called inside handleContentSizeChange. 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:

    1. Only record baseline height when input is truly empty:
      Update the condition in handleContentSizeChange so emptyComposerHeightRef.current is 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.

    2. Auto-release temporary height lock after clear:
      In resetHeight(), schedule clearComposerHeight() via requestAnimationFrame so 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:

    1. When handleContentSizeChange fires with non-empty text lacking newlines (e.g. wrapped draft), verify that emptyComposerHeightRef.current is not set.
    2. When handleContentSizeChange fires with empty text (""), verify that emptyComposerHeightRef.current is recorded.
    3. Verify that sending a multi-line or wrapped message resets the composer to the single-line height and releases the fixed height lock.
  8. melvin-bot commented on Oct 8, 2026

    @melvin-bot

    ⚠️ Unable to store contributor details

    Details
    Auth SetContributorDetails returned an error
    401 Contributor details already exist
    
  9. krsnak commented on Oct 8, 2026

    @krsnak

    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.current when 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.

  10. ashusatyarthi-wq commented on Oct 8, 2026

    @ashusatyarthi-wq

    Contributor details
    Your Expensify account email: ashusatyarthi@gmail.com
    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;
    }
    1. The code attempts to cache the baseline empty collapsed composer height into emptyComposerHeightRef.current. However, it guards with !valueRef.current.includes('\n').
    2. When a chat is opened with an existing restored draft that visually wraps onto 2 lines without containing an explicit newline (\n), the first handleContentSizeChange measurement captures the 2-line wrapped height and erroneously stores it into emptyComposerHeightRef.current.
    3. When the user submits the draft without editing, resetHeight() (lines 850–855) sets composerHeightAfterClear to emptyComposerHeightRef.current (2-line height).
    4. clearComposerHeight() is only triggered when a subsequent handleContentSizeChange or onChangeText event 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:

    1. 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.

    1. 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.current cleanly 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 via requestAnimationFrame.
    • If the chat was opened with an existing draft (where emptyComposerHeightRef was never set), resetHeight() explicitly resets setComposerHeightAfterClear(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.
  11. melvin-bot commented on Oct 8, 2026

    @melvin-bot

    ✅ Contributor details stored successfully. Thank you for contributing to Expensify!

  12. jloa-dev commented on Oct 10, 2026

    @jloa-dev

    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:

    1. 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:

    1. 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;
    }
    1. In resetHeight(), if emptyComposerHeightRef.current was not recorded (e.g., opened with an existing long draft), reset setComposerHeightAfterClear(null) immediately to allow native flex layout to settle at single-line height.
    2. 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: jloa.dev@gmail.com
    Upwork Profile Link: https://www.upwork.com/freelancers/~0163955a2ba22190aa

  13. 34 remaining items

  14. melvin-bot commented on Nov 3, 2026

    @melvin-bot

    @situchan 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  15. melvin-bot commented on Nov 4, 2026

    @melvin-bot

    @situchan 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  16. melvin-bot commented on Nov 4, 2026

    @melvin-bot

    @situchan 8 days overdue is a lot. Should this be a Weekly issue? If so, feel free to change it!

  17. situchan commented on Nov 4, 2026

    @situchan
    Contributor

    @MelvinBot draft implementation for your proposal

  18. MelvinBot commented on Nov 4, 2026

    @MelvinBot
    Contributor

    🤖 Web test steps verification results: ❌ fail

    The supplied web session displayed a blank page, so no composer behavior could be tested. This is not a confirmed regression.

    Blank page blocked composer verification

    Step Status
    Open a DM with an empty, one-line composerBlocked: no accessible UI rendered.
    Blank page blocked composer verification
    ❌
    Type a single line that wraps to two lines without EnterNot executed because the app UI was unavailable.
    ❌
    Switch chats and verify the wrapped draft is restoredNot executed because the app UI was unavailable.
    ❌
    Send the restored draft without editing; composer returns to and remains one lineNot executed because the app UI was unavailable.
    ❌
    Send a freshly typed wrapped message; composer returns to one lineNot executed because the app UI was unavailable.
    ❌
    Send an expanded multiline message without cursor/placeholder flash or height regressionNot executed because the app UI was unavailable.
    ❌

    Created draft implementation: Prevent restored drafts from keeping the empty composer expanded, assigned to situchan. All 37,016 executed Jest tests passed, including seven new regression cases. Lint, types, spelling, explicit-path React Compiler checks, and Storybook smoke checks passed. The formatter check was unavailable; details are in the PR.

    Please complete web verification before marking the draft ready for review.


    view run · no recording available

  19. melvin-bot commented on Nov 5, 2026

    @melvin-bot

    @situchan this issue is now 4 weeks old, please consider:

    • Finding a contributor to fix the bug
    • Closing the issue if BZ has been unable to add the issue to a VIP or Wave project
    • If you have any questions, don't hesitate to start a discussion in #expensify-open-source

    Thanks!

  20. jeffrey-graham commented on Nov 7, 2026

    @jeffrey-graham
  21. melvin-bot commented on Nov 7, 2026

    @melvin-bot
  22. melvin-bot commented on Nov 10, 2026

    @melvin-bot

    @situchan Eep! 4 days overdue now. Issues have feelings too...

  23. AndrewGable commented on Nov 13, 2026

    @AndrewGable
    Contributor

    I can't reproduce anymore, I think we can close. If anyone disagrees, let me know

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2ExternalAdded to denote the issue can be worked on by a contributorNeeds ReproductionReproducible steps needed

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions