Skip to content

Fix landscape mode layout on Agents pages - #97782

Draft
GCyganek wants to merge 2 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/landscape-mode/fix-agent-pages
Draft

Fix landscape mode layout on Agents pages#97782
GCyganek wants to merge 2 commits into
Expensify:mainfrom
software-mansion-labs:@GCyganek/landscape-mode/fix-agent-pages

Conversation

@GCyganek

@GCyganek GCyganek commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Explanation of Change

Changes from #97214 and #94565 that were reverted because of this #97196 (comment)

Fixes landscape layout on Agents/Agent Rules pages when the keyboard is open. Replaces the scrollable-form layout with a collapsing header, shrinks multiline prompt inputs to a fixed height while the keyboard is active, and renders Save/Delete in one row in landscape.

Also corrects the header collapse math for the top safe area inset. Fixes not restoring header height after device rotation to portrait mode. Also adding isKeyboardFullyOpen check and add naturalHeightRef.current !== height comparison in onLayout to make sure duplicated onLayout height updates do not cancel ongoing animationwhen rotating from portrait to landscape with opened keyboard

Fixed Issues

$ #93631, #97196
PROPOSAL: N/A

Tests

Test 1: Add agent page in landscape

  1. Rotate the device to landscape mode
  2. Go to Account settings > Workspaces > [workspace] > Agents > Add agent (or Settings > Agents > Add agent)
  3. Tap the Prompt multiline input to open the keyboard
  4. Verify that the prompt input shrinks to ~2 visible lines instead of stretching behind the keyboard, and that the input is scrolled into view (check specifically on iOS native)
  5. Type a multi-line prompt and verify the text is visible while typing and the Save button remains reachable
  6. Dismiss the keyboard and verify the header expands back to its full height and the prompt input grows back to fill the available space
  7. Rotate back to portrait and verify the layout is unchanged from before this PR (full-height prompt input, no header collapsing)

Test 2: Edit agent rule in landscape (Save + Delete in one row)

  1. In landscape mode, go to Workspace settings > Rules > Agent rules and open an existing rule (Edit rule page)
  2. Focus the rule prompt input to open the keyboard
  3. Verify the prompt input shrinks, and both the Delete and Save buttons are visible side by side in a single row
  4. Dismiss the keyboard and verify the layout restores
  5. Rotate to portrait and verify Delete and Save are stacked vertically as before

Test 3: Add agent rule tabs + Profile page

  1. In landscape mode, go to Workspace settings > Rules > Agent rules > Add rule
  2. On the Suggestions tab, focus the search input to open the keyboard and verify the header + tab selector collapse and the Next button scrolls inside the list content instead of being pinned as a fixed footer behind the keyboard
  3. Switch to the Write tab, focus the prompt input, and verify the headline/description collapse, the prompt input shrinks, and the submit button stays visible
  4. Go to Account settings > Profile, still in landscape, and focus any input on the page
  5. Verify the profile header collapses on keyboard open and expands again on keyboard close, and that no content is clipped
  • Verify that no errors appear in the JS console

Offline tests

N/A

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 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 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: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari

@melvin-bot

melvin-bot Bot commented Aug 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!

@codecov

codecov Bot commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ Changes either increased or maintained existing code coverage, great job!

Files with missing lines Coverage Δ
src/components/Form/FormProvider.tsx 65.94% <ø> (ø)
src/components/Form/FormWrapper.tsx 90.76% <100.00%> (+0.14%) ⬆️
src/components/FormAlertWithSubmitButton.tsx 97.50% <100.00%> (+0.35%) ⬆️
src/pages/settings/Agents/AddAgentPage.tsx 93.75% <100.00%> (+0.41%) ⬆️
...rc/pages/settings/Agents/Fields/EditPromptPage.tsx 71.42% <100.00%> (+0.69%) ⬆️
src/pages/settings/Agents/const.ts 100.00% <100.00%> (ø)
...ce/rules/AgentRules/AddAgentRuleSuggestionsTab.tsx 98.27% <100.00%> (+0.12%) ⬆️
...es/settings/Agents/scrollToMultilineInput/index.ts 0.00% <0.00%> (ø)
src/pages/settings/Profile/ProfilePage.tsx 95.09% <60.00%> (ø)
...ettings/Agents/scrollToMultilineInput/index.ios.ts 0.00% <0.00%> (ø)
... and 4 more
... and 11 files with indirect coverage changes

@GCyganek

GCyganek commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@m-natarajan would you be able to check if this is still happening for you here? I tested Android on different simulators and on my Android 16 physical device, but I'm not able to reproduce this bug so I just want to confirm this needs a separate fix

Screen.Recording.2026-08-04.at.13.15.58.mov

@m-natarajan

Copy link
Copy Markdown

@GCyganek
Xiaomi Redmi Note 10 / Android 12
App 9.4.49-1
Passed

Screenrecorder-2026-08-04-16-40-08-799.mp4

@GCyganek

GCyganek commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

@m-natarajan thank you, from what I see you tested version without the changes from this PR, but the bug I linked in my previous comment is what caused the revert, so I wanted to make sure it is not reproducible on this PR. Are you able to do that in any way? I'd be really grateful as I can't reproduce it on my end, but you were able to first time these changes were merged to main. I can ask someone for an ad-hoc build if it's needed

@m-natarajan

Copy link
Copy Markdown

@GCyganek Share the Ad-hoc build when its ready and ping, Will retest the same.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

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

@GCyganek

GCyganek commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@m-natarajan build is ready

@m-natarajan

Copy link
Copy Markdown

@GCyganek Passed in the Ad-hoc build

Screenrecorder-2026-08-05-17-23-28-822.mp4

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.

2 participants