Skip to content

fix report title box is not scrolled to the bottom after pasting several lines of text - #100392

Merged
chuckdries merged 4 commits into
Expensify:mainfrom
apeyada:fix-99715
Sep 15, 2026
Merged

chuckdries merged 4 commits into
Expensify:mainfrom
apeyada:fix-99715

Conversation

@apeyada

@apeyada apeyada commented Sep 4, 2026 •

Copy link
Copy Markdown

Explanation of Change

getAutoGrowHeightInputStyle gives an autoGrowHeight input a fixed height and overflow: hidden while it is growing, then drops the fixed height and switches to overflow: auto once the content passes maxAutoGrowHeight.

The fixed height was 12px taller than the height the input actually gets after that flip - the formula subtracted the label padding and the borders, but not the container's own padding: 8 or its pb1:

fixed height while growing 115 - inputPaddingTop (15) - borderWidth x 2 (2) = 98
real height after the flip 115 - borders (2) - padding (8) - pb1 (4) - label padding (15) = 86

So a paste scrolls the caret into view against the stale 98px box, then the box shrinks to 86px and nothing re-scrolls - leaving the view 12px short of the end, constant regardless of how much was pasted.

This makes the two heights agree instead of correcting the offset afterwards. A new StyleUtils.getAutoGrowHeightInputVerticalInset reads the borders and padding off the flattened container style (so pt0 / p0 / pb1 / consumer overrides are honoured) and getAutoGrowHeightInputStyle uses maxHeight - verticalInset. Both BaseTextInput implementations pass it from the container styles they already build.

The 4-line maximum before the flip is 80px, still under 86, so the input still never scrolls while growing and no scrollbar flashes.

This is not a regression from #97489 - it is live in production on every non-markdown auto-grow input, so the fix also covers CloseAccountPage, RejectExpenseReportPage, DynamicExitSurveyReasonPage, ReportsDefaultTitle and SamlConfigurationDetailsSectionContent.

Fixed Issues

$ #99715
PROPOSAL: #99715 (comment)

Tests

Prerequisite: Copy several lines of text from a chat or document. (More than 5 lines)

  1. Open any workspace chat.
  2. Create a manual expense.
  3. Open the just created expense and click on the title to edit it.
  4. Delete the original title and paste the copied text on the title box.
  5. Verify that title box is autoscrolled to the bottom and the end of the title is visible.
  • Verify that no errors appear in the JS console

Offline tests

Same as Tests

QA Steps

Same as Tests

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

Screenshots/Videos

Android: Native
android.mov
Android: mWeb Chrome
mchrome.mov
iOS: Native
ios.mov
iOS: mWeb Safari
msafari.mov
MacOS: Chrome / Safari
web.mov

@melvin-bot

melvin-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers!

@melvin-bot
melvin-bot Bot requested review from flaviadefaria and inimaga and removed request for a team September 4, 2026 11:33
@melvin-bot

melvin-bot Bot commented Sep 4, 2026

Copy link
Copy Markdown

@inimaga 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]

@codecov

codecov Bot commented Sep 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/styles/utils/index.ts 61.06% <100.00%> (+1.13%) ⬆️
...nput/BaseTextInput/implementation/index.native.tsx 82.66% <33.33%> (-0.30%) ⬇️
...s/TextInput/BaseTextInput/implementation/index.tsx 0.00% <0.00%> (ø)
... and 9 files with indirect coverage changes

@inimaga

inimaga commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

@apeyada Is this PR ready for review? Its missing the appropriate screenshots and videos. Could you also dial back the overly verbose nature of the PR description.

cc: @mkhutornyi & @chuckdries

@inimaga
inimaga requested review from chuckdries and mkhutornyi and removed request for inimaga September 4, 2026 15:05
@apeyada

apeyada commented Sep 6, 2026

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: d7e066d02b

ℹ️ 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".

@apeyada

apeyada commented Sep 6, 2026

Copy link
Copy Markdown
Author

PR is ready for review.

Note: On mobile safari, scroll doesn't happen at all but it's a different bug happening on production with different root cause.

mobile.safari.mov

@mkhutornyi

Copy link
Copy Markdown

@MelvinBot review

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 Review — approve with non-blocking suggestions

The diagnosis and the fix hold up. I re-derived the arithmetic against the real style tree and it lands exactly where the PR says:

  • Growing (fixed height): 115 - (1 + 1 + 8 + 4 + 15) = 86
  • After the flip (natural flex height): wrapper clamped to 115 by autoGrowHeightInputContainer → container height: '100%' minus 2 borders minus padding: 8 / pb1: 4 = 101 → textInputMultilineContainer height: '100%' minus paddingTop: 15 = 86

They now agree, so the box no longer resizes under the browser's scroll offset. The tallest pre-flip content is 4 lines (15 + 8 + 20 × 5 = 123 > 115) = 80px, which still fits in 86, so no scrollbar flash. All CI checks pass except Check independent approval.

Suggestions (none blocking)

1. The label-padding term is coupled by coincidence. getAutoGrowHeightInputVerticalInset adds variables.inputPaddingTop, but the padding it compensates for is styles.textInputMultilineContainer.paddingTop. Those are equal only because of how that style happens to be defined — change one and the inset silently goes stale, which is the same class of drift this PR is fixing. The function needs no theme, only styles, so moving it into createStyleUtils would let it read styles.textInputMultilineContainer.paddingTop directly.

2. isMultiline && hasLabel is computed twice per file. Once for the inset (web:360, native:301) and once where the style is actually applied (web:433, native:356). One const used in both places keeps them from diverging.

3. getMarkdownMaxHeight still carries the formula this PR just disproved. src/styles/utils/index.ts:1600 is maxAutoGrowHeight - textInputMultilineContainer.paddingTop - borderWidth * 2 — the exact expression being replaced. The markdown container also gets pb2 on top of padding: 8, so its real inset is 33, not 17. Out of scope for #99715 and I did not verify a user-visible symptom there, but leaving the stale copy next to the new helper invites the bug back. Worth a follow-up.

4. Near-duplicate of the helper directly above it. getVerticalPaddingDiffFromStyle has the same StyleSheet.flatten + identical local getNumericValue, but does not consider paddingVertical while the new one does. Two extractors that disagree on precedence is a footgun; consider one shared padding reader.

5. Test nits. The two branches the new helper adds over the existing one — paddingVertical and explicit borderTopWidth/borderBottomWidth — have no coverage. And AutoGrowHeightInputStyleUtilsTest.ts:55 hardcodes - 8 where it means variables.inputPaddingBottom, so the assertion won't follow a pixel-ratio change. Separately, every autoGrowHeight consumer I checked passes a label, so the "skips the label padding when there is no label" case guards a path with no current caller — correct, just not load-bearing.


🤖 Web test steps verification results: ✅ pass

I ran the PR's test steps on the fix-99715 branch. The title box grows, flips to internal scroll past its max height, and lands with the end of the text visible — no manual scrolling and no layout jump.

Step 5 - title box autoscrolled to the bottom

Step Status
Open any workspace chatNo workspace existed on the test account, so one was created, then its expense chat was opened.
Step 1 - workspace chat opened
✅
Create a manual expenseCreated a $25.00 "Coffee Shop" manual expense; it appeared as a draft Expense Report.
Step 2 - manual expense created
✅
Open the expense and click the title to edit itThe Title edit screen opened with the field pre-filled.
Step 3 - title edit screen open
✅
Delete the original title and enter more than 5 lines of textReplaced the full contents (confirmed by read-back) with a 148-character string that wraps to 6 lines. A real clipboard paste isn't available on the web driver, so this used typed input that wraps past the auto-grow threshold — the same code path.
Step 4 - title replaced with 6 wrapped lines
✅
Title box is autoscrolled to the bottom, end of text visible, no scrollbar flashThe first lines are clipped at the top and the final line ("3333 END") is fully visible at the bottom with no manual scrolling. A repeat capture immediately after showed an identical layout, so no flash or jump.
Step 5 - title box autoscrolled to the bottom
✅

Console errors could not be captured — log collection is unsupported for web in this session.

@mkhutornyi

mkhutornyi commented Sep 7, 2026 •

Copy link
Copy Markdown

Reviewer Checklist

  • I have verified the author checklist is complete (all boxes are checked off).
  • I verified the correct issue is linked in the ### Fixed Issues section above
  • I verified testing steps are clear and they cover the changes made in this PR
    • I verified the steps for local testing are in the Tests section
    • I verified the steps for Staging and/or Production testing are in the QA steps section
    • I verified the steps cover any possible failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
  • I checked that screenshots or videos are included for tests on all platforms
  • I included screenshots or videos for tests on all platforms
  • I verified that the composer does not automatically focus or open the keyboard on mobile unless explicitly intended. This includes checking that returning the app from the background does not unexpectedly open the keyboard.
  • I verified tests pass on all platforms & I tested again on:
    • Android: HybridApp
    • Android: mWeb Chrome
    • iOS: HybridApp
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • If there are any errors in the console that are unrelated to this PR, I either fixed them (preferred) or linked to where I reported them in Slack
  • I verified proper code patterns were followed (see Reviewing the code)
    • I verified that any callback methods that were added or modified are named for what the method does and never what callback they handle (i.e. toggleReport and not onIconClick).
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I verified that this PR follows the guidelines as stated in the Review Guidelines
  • I verified other components that can be impacted by these changes have been tested, and I retested again (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar have been tested & I retested again)
  • If a new component is created I verified that:
    • A similar component doesn't exist in the codebase
    • All props are defined accurately and each prop has a /** comment above it */
    • The file is named correctly
    • The component has a clear name that is non-ambiguous and the purpose of the component can be inferred from the name alone
    • The only data being stored in the state is data necessary for rendering and nothing else
    • For Class Components, any internal methods passed to components event handlers are bound to this properly so there are no scoping issues (i.e. for onClick={this.submit} the method this.submit should be bound to this in the constructor)
    • Any internal methods bound to this are necessary to be bound (i.e. avoid this.submit = this.submit.bind(this); if this.submit is never passed to a component event handler like onClick)
    • All JSX used for rendering exists in the render method
    • The component has the minimum amount of code necessary for its purpose, and it is broken down into smaller components in order to separate concerns and functions
  • If any new file was added I verified that:
    • The file has a description of what it does and/or why is needed at the top of the file if the code is not self explanatory
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • For any bug fix or new feature in this PR, I verified that sufficient unit tests are included to prevent regressions in this flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.
  • I have checked off every checkbox in the PR reviewer checklist, including those that don't apply to this PR.

Screenshots/Videos

Android: HybridApp
android.ios.mov
Android: mWeb Chrome
iOS: HybridApp
android.ios.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mov

@chuckdries chuckdries left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is an issue, but it seems like it may end up not scrolling when it should (maybe only an edge case with non-standard font sizes or zoom levels?)

Comment thread src/styles/utils/index.ts Outdated
*/
getAutoGrowHeightInputStyle: (textInputHeight: number, maxHeight: number): ViewStyle => {
getAutoGrowHeightInputStyle: (textInputHeight: number, maxHeight: number, verticalInset: number): ViewStyle => {
if (textInputHeight > maxHeight) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand why this shouldn't be

Suggested change
if (textInputHeight > maxHeight) {
if (textInputHeight > (maxHeight - verticalInset)) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textInputHeight isn't the height of the text. It's the height of the hidden <Text> we measure with, and that one still carries baseTextInput's paddingTop: 15 / paddingBottom: 8 (the real input has them zeroed by pv0).
So it's 23 + lines × 20, which is the same scale as maxAutoGrowHeight - the container height is literally textInputHeight + 8.
verticalInset takes you out of that scale and into the input's own box, so subtracting it here compares two different things.

In practice it would flip one line too early.
At 4 lines textInputHeight is 103 and the container is 111 tall, so there's 82px of room for 80px of text - it fits fine, nothing needs to scroll.
But 103 > 115 - 29 is true, so we'd drop the fixed height and switch to overflow: auto anyway, which is the scrollbar flash the fixed height is there to prevent.

@apeyada apeyada left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is an issue, but it seems like it may end up not scrolling when it should (maybe only an edge case with non-standard font sizes or zoom levels?)

You're right that there's a case where it doesn't scroll when it should, but it takes a font scale around 1.1 (~110% zoom) and exactly 4 lines, and then ~3px of the last line is out of reach.
It's not new either:

  • before this PR, the container clipped those same 3px and you couldn't scroll to them at all
  • now the input can at least be scrolled.

I think we can leave this threshold out of scope for this PR as it's a separate pre-existing edge, and changing it moves the flip point for every auto-grow input.
Happy to look at it separately though. The proper fix is to subtract the measuring padding from textInputHeight first, so both sides of the comparison are content heights.

Comment thread src/styles/utils/index.ts Outdated
*/
getAutoGrowHeightInputStyle: (textInputHeight: number, maxHeight: number): ViewStyle => {
getAutoGrowHeightInputStyle: (textInputHeight: number, maxHeight: number, verticalInset: number): ViewStyle => {
if (textInputHeight > maxHeight) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

textInputHeight isn't the height of the text. It's the height of the hidden <Text> we measure with, and that one still carries baseTextInput's paddingTop: 15 / paddingBottom: 8 (the real input has them zeroed by pv0).
So it's 23 + lines × 20, which is the same scale as maxAutoGrowHeight - the container height is literally textInputHeight + 8.
verticalInset takes you out of that scale and into the input's own box, so subtracting it here compares two different things.

In practice it would flip one line too early.
At 4 lines textInputHeight is 103 and the container is 111 tall, so there's 82px of room for 80px of text - it fits fine, nothing needs to scroll.
But 103 > 115 - 29 is true, so we'd drop the fixed height and switch to overflow: auto anyway, which is the scrollbar flash the fixed height is there to prevent.

@chuckdries

Copy link
Copy Markdown
Contributor

If we're going to fix it, let's fix it properly IMO. Can you try to implement the hidden sizing changes here?

@apeyada

apeyada commented Sep 13, 2026

Copy link
Copy Markdown
Author

@chuckdries addressed

@chuckdries
chuckdries merged commit c17238a into Expensify:main Sep 15, 2026
34 of 35 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

🚧 chuckdries has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify

Copy link
Copy Markdown
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/chuckdries in version: 9.4.80-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 No help site changes are required. I did not create a docs PR.

Why: this PR only corrects a pixel-height calculation inside a shared text input component. It adds StyleUtils.getAutoGrowHeightInputVerticalInset and makes getAutoGrowHeightInputStyle subtract that inset, so the box a growing input gets matches the box it gets after it flips to overflow: auto. The result is that pasting long text into a report title scrolls to the end instead of stopping 12px short.

That restores the behavior a user already expects. It does not change any feature, field, setting, tab, button, or workflow, and it adds no new copy.

What I checked
  • Full diff: 4 files, all in src/components/TextInput/BaseTextInput/implementation/, src/styles/utils/index.ts, and a new unit test. No src/languages/*, no new UI strings.
  • Searched docs/articles for report/expense title and editing content. The closest articles are Customize-and-Enforce-Report-Titles.md and Create-and-Submit-Reports.md. Both describe how to set and enforce report titles — neither documents the scroll or sizing behavior of the title input, so neither needs an edit.
  • Per HELP_AUTHORING_GUIDELINES.md, help articles cover what customers can do and how, not rendering fixes. Adding a note about this would be noise for the reader.

apeyada — there is no help site PR to link, so nothing needs to be marked Ready for review. If you want the docs updated anyway, tell me which article and what you want it to say and I'll open the draft PR.


view run

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/luacmartins in version: 9.4.80-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 failure ❌

Bundle Size Analysis (Sentry):

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants