Skip to content

fix: android - save button floats in center of the screen after edit#82536

Merged
Julesssss merged 9 commits intoExpensify:mainfrom
ikevin127:ikevin127-saveButtonFloating
Mar 19, 2026
Merged

fix: android - save button floats in center of the screen after edit#82536
Julesssss merged 9 commits intoExpensify:mainfrom
ikevin127:ikevin127-saveButtonFloating

Conversation

@ikevin127
Copy link
Contributor

@ikevin127 ikevin127 commented Feb 16, 2026

Explanation of Change

FormProvider currently gates form submission behind KeyboardUtils.dismiss().then(() => onSubmit(...)), which on Android waits for the keyboardDidHide event before calling onSubmit. Combined with KeyboardAvoidingView removing its keyboard offset once the keyboard is considered hidden, this creates a brief window where the Save button has lost its keyboard offset but the screen hasn't navigated away yet, making it float in the center of the screen.

This PR adds a new optional prop shouldDismissKeyboardBeforeSubmit to FormProvider (defaulting to true to preserve all existing behavior). When set to false, onSubmit fires immediately while keyboard dismissal happens in parallel. IOURequestStepDescription passes shouldDismissKeyboardBeforeSubmit={false} so the navigation transition and keyboard animation happen simultaneously instead of sequentially.

Fixed Issues

$ #72507
PROPOSAL: #72507 (comment)

Tests

  1. Open any expense with a description.
  2. Tap on the Description field to edit it.
  3. Type something (ensure the soft keyboard is visible).
  4. Tap Save.
  5. Verify that the Save button does not float in the center of the screen, the keyboard should animate down and the page should close simultaneously.
  • 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 verified there are no new alerts related to the canBeMissing param for useOnyx
  • 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 shown in the product is localized by adding it to src/languages/* files and using the translation method
      • If any non-english text was added/modified, I used JaimeGPT to get English > Spanish translation. I then posted it in #expensify-open-source and it was approved by an internal Expensify engineer. Link to Slack message:
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • I verified that if a function's arguments changed that all usages have also been updated correctly
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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.mp4
Android: mWeb Chrome
android-mweb.mp4
iOS: Native
ios.mov
iOS: mWeb Safari
ios-mweb.mov
MacOS: Chrome / Safari
Screen.Recording.2026-02-16.at.14.44.08.mov

@melvin-bot
Copy link

melvin-bot bot commented Feb 16, 2026

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

@codecov
Copy link

codecov bot commented Feb 16, 2026

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/CONST/index.ts 93.54% <ø> (ø)
...ges/iou/request/step/IOURequestStepDescription.tsx 0.00% <ø> (ø)
...ssKeyboardBeforeDescriptionSubmit/index.android.ts 0.00% <0.00%> (ø)
...uldDismissKeyboardBeforeDescriptionSubmit/index.ts 0.00% <0.00%> (ø)
src/utils/keyboard/index.website.ts 0.00% <0.00%> (ø)
src/components/Form/FormProvider.tsx 59.00% <42.85%> (-0.80%) ⬇️
... and 11 files with indirect coverage changes

@ikevin127 ikevin127 marked this pull request as ready for review February 16, 2026 22:53
@ikevin127 ikevin127 requested review from a team as code owners February 16, 2026 22:53
@melvin-bot
Copy link

melvin-bot bot commented Feb 16, 2026

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

@melvin-bot melvin-bot bot removed request for a team and heyjennahay February 16, 2026 22:53
@ikevin127
Copy link
Contributor Author

Solution deviation from initial proposal

The initial proposal introduced a simple boolean prop shouldDismissKeyboardBeforeSubmit to decouple keyboard dismissal from form submission. During cross-platform testing, we discovered that keyboard timing behavior differs significantly across four distinct platform contexts, not just two:

Platform Boolean false (just onSubmit) Boolean false + dismiss() fire-and-forget
Android native ✅ Works — navigation auto-dismisses keyboard ✅ Works
iOS native ❌ Button hangs — keyboard stays, KeyboardAvoidingView still active ✅ Works
iOS mweb Safari ✅ Works ❌ Button hangs
Android mweb Chrome ✅ Works ✅ Works

No single boolean value + behavior worked across all platforms. The root cause is that each platform's keyboard utility (KeyboardUtils) resolves differently:

  • iOS native dismiss() waits for keyboardDidHide → introduces a visible delay before navigation
  • iOS native dismissKeyboardAndExecute() → fires the callback immediately (no waiting)
  • Android native both dismiss() and dismissKeyboardAndExecute() wait for keyboardDidHide → causes the floating button
  • Web/mweb dismissKeyboardAndExecute() → fires the callback immediately

This required three distinct strategies instead of two:

  1. dismiss-then-submit (default) — existing behavior for forms that stay on-screen after submission
  2. submit-and-dismiss — uses dismissKeyboardAndExecute(), which fires onSubmit immediately on iOS native and web (both resolve instantly), fixing the delay on iOS and the hang on Android mweb
  3. submit-only — just calls onSubmit() with no keyboard handling at all, needed only for Android native where navigation automatically cleans up the keyboard

The platform-specific files then select the right strategy per build target:

  • index.ts (web + iOS native) → submit-and-dismiss
  • index.android.ts (Android native) → submit-only

cc @parasharrajat for context

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 92886930c1

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

Comment on lines +276 to +277
} else if (keyboardSubmitBehavior === CONST.KEYBOARD_SUBMIT_BEHAVIOR.SUBMIT_AND_DISMISS) {
KeyboardUtils.dismissKeyboardAndExecute(() => onSubmit(trimmedStringValues));

Choose a reason for hiding this comment

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

P2 Badge Make submit-and-dismiss invoke keyboard dismissal on all platforms

The new SUBMIT_AND_DISMISS branch routes submission through KeyboardUtils.dismissKeyboardAndExecute, but the iOS (src/utils/keyboard/index.ts) and web (src/utils/keyboard/index.website.ts) implementations of that helper only run the callback and never call Keyboard.dismiss(). As a result, keyboardSubmitBehavior='submit-and-dismiss' does not actually dismiss the keyboard, so this change regresses IOURequestStepDescription from the previous always-dismiss behavior and can leave the keyboard visible when navigation is delayed or does not complete.

Useful? React with 👍 / 👎.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TLDR: The reviewer spotted that the function name suggests it dismisses the keyboard but doesn't on iOS/web — that's by design. The keyboard is dismissed by screen unmounting during navigation, which was confirmed across all platforms. Not actionable.

The concern is technically accurate but not a practical regression. Here's why:

The reviewer is correct that dismissKeyboardAndExecute on iOS native and web doesn't call Keyboard.dismiss() — it just executes the callback immediately. You can see this in the code comments themselves:

// index.ts (iOS native)
const dismissKeyboardAndExecute = (cb: () => void): Promise<void> => {
    // For iOS and other platforms, execute callback immediately
    cb();
    resolve();
};
// index.website.ts (web)
const dismissKeyboardAndExecute = (cb: () => void): Promise<void> => {
    // This fixes a bug specific to native apps on Android < 16
    // For web it just executes callback
    cb();
    resolve();
};

However, it's not a regression because:

  1. Navigation handles keyboard cleanup. When onSubmit runs in IOURequestStepDescription, it calls Navigation.goBack() which unmounts the screen. The focused TextInput unmounts → the keyboard dismisses automatically. This is standard React Native behavior.
  2. This was verified on all 4 platform contexts (Android native, iOS native, Android mweb Chrome, iOS mweb Safari) during testing — the keyboard always dismissed.
  3. The "navigation delayed or doesn't complete" edge case is not applicable hereupdateComment in IOURequestStepDescription calls goBack() synchronously. By the time we reach the submit callback, validation has already passed (there's an early return for validation errors before the keyboard logic).
  4. Adding Keyboard.dismiss() back would re-introduce the bugs we just fixed — specifically the hanging button on iOS mweb Safari, which was the exact reason we moved away from the boolean approach.
  5. dismissKeyboardAndExecute was built intentionally this way — it's an existing utility in the codebase designed specifically for the "execute immediately, let the platform handle keyboard cleanup" pattern. We're using it as intended.

@chatgpt-codex-connector
Copy link

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

We were unable to download your code in a timely manner.
ℹ️ 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".

@parasharrajat
Copy link
Member

Checking this today. I was away last week.

if (keyboardSubmitBehavior === CONST.KEYBOARD_SUBMIT_BEHAVIOR.DISMISS_THEN_SUBMIT) {
KeyboardUtils.dismiss().then(() => onSubmit(trimmedStringValues));
} else if (keyboardSubmitBehavior === CONST.KEYBOARD_SUBMIT_BEHAVIOR.SUBMIT_AND_DISMISS) {
KeyboardUtils.dismissKeyboardAndExecute(() => onSubmit(trimmedStringValues));
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment mentioning here that on IOS and web, this function does not actually dismiss the keyboard?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a detailed comment above the keyboardSubmitBehavior prop for each behaviour:

    /**
     * Controls how keyboard dismissal interacts with form submission.
     * - `DISMISS_THEN_SUBMIT` (default): waits for the keyboard to fully dismiss before calling `onSubmit`.
     * - `SUBMIT_AND_DISMISS`: calls `onSubmit` immediately while dismissing the keyboard in parallel via `dismissKeyboardAndExecute`.
     * - `SUBMIT_ONLY`: calls `onSubmit` immediately without any keyboard dismissal (navigation handles keyboard cleanup).
     */
    keyboardSubmitBehavior?: ValueOf<typeof CONST.KEYBOARD_SUBMIT_BEHAVIOR>;

and if somebody is curious, they can navigate to dismissKeyboardAndExecute individual functions (index.ts / index.android.ts) where there's another comment mentioning (index.ts):

// For iOS and other platforms, execute callback immediately

Additionally, the blame of my changes lead directly to this PR / issue in case more context is needed.
I think this is documented enough ✅

@parasharrajat
Copy link
Member

Looking into this now.

@parasharrajat
Copy link
Member

Screenshots

🔲 iOS / native

🔲 iOS / Safari

🔲 MacOS / Chrome

🔲 Android / Chrome

🔲 Android / native

@parasharrajat
Copy link
Member

Checking this now... I will have updates on this in the morning.

@parasharrajat
Copy link
Member

@ikevin127 Please merge main here. Its outdated. Looking for other similar pages.

@parasharrajat
Copy link
Member

@MelvinBot We updated the src/pages/iou/request/step/IOURequestStepDescription.tsx component in this PR has it has floating submit button issue. Are there more pages in the app with the same issue? Do the code analsis based on how IOURequestStepDescription is designed and see if other pages are using similiar pattern.

@MelvinBot
Copy link
Contributor

Analysis: Other Pages with the Same Floating Submit Button Pattern

I analyzed the pattern fixed in IOURequestStepDescription.tsx in this PR and searched the codebase for other pages that are susceptible to the same issue. The core problem: FormProvider defaults to dismiss-then-submit, which on Android causes KeyboardAvoidingView to remove its keyboard offset before the screen finishes unmounting — making the submit button appear to float.

Pages vulnerable to this issue share these traits:

  1. Use <FormProvider> with an onSubmit that triggers navigation (e.g., Navigation.goBack())
  2. Contain text inputs that open the soft keyboard
  3. Do not set keyboardSubmitBehavior (using the default DISMISS_THEN_SUBMIT)

High-Confidence Matches (same pattern as IOURequestStepDescription)

These pages have text inputs, navigate on submit, and are most likely to exhibit the floating button:

IOU/Money Request Steps

File onSubmit navigates? Text input?
src/pages/iou/request/step/IOURequestStepMerchant.tsx Yes Yes (merchant name)
src/pages/iou/request/step/IOURequestStepDate.tsx Yes (navigateBack()) Yes (date picker)
src/pages/iou/request/step/IOURequestStepWaypoint.tsx Yes Yes (address search)
src/pages/iou/request/step/IOURequestStepCompanyInfo.tsx Yes Yes
src/pages/iou/request/step/IOURequestStepSubrate.tsx Yes Yes
src/pages/iou/request/step/IOURequestStepTime.tsx Yes Yes

Settings / Profile Pages

File onSubmit navigates? Text input?
src/pages/settings/Profile/DisplayNamePage.tsx Yes (Navigation.goBack()) Yes (first/last name)
src/pages/settings/Profile/PersonalDetails/PhoneNumberPage.tsx Yes (Navigation.goBack()) Yes (phone)
src/pages/settings/Profile/PersonalDetails/BaseLegalNamePage.tsx Yes (Navigation.goBack()) Yes (legal names)
src/pages/settings/Profile/CustomStatus/StatusPage.tsx Yes (Navigation.goBack()) Yes (status text)
src/pages/settings/Profile/Contacts/NewContactMethodPage.tsx Yes (navigates) Yes (email/phone)
src/pages/settings/Report/RoomNamePage.tsx Yes (Navigation.goBack()) Yes (room name)

Chat / Room / Task Pages

File onSubmit navigates? Text input?
src/pages/GroupChatNameEditPage.tsx Yes (Navigation.goBack()) Yes (chat name)
src/pages/TripChatNameEditPage.tsx Yes (Navigation.goBack()) Yes (trip name)
src/pages/RoomDescriptionPage.tsx Yes (Navigation.goBack()) Yes (description, markdown)
src/pages/tasks/NewTaskTitlePage.tsx Yes (Navigation.goBack()) Yes (title)
src/pages/tasks/TaskTitlePage.tsx Yes (dismissModalWithReport()) Yes (title)
src/pages/tasks/NewTaskDescriptionPage.tsx Yes Yes (description)
src/pages/tasks/TaskDescriptionPage.tsx Yes Yes (description)
src/pages/PrivateNotes/PrivateNotesEditPage.tsx Yes (navigates) Yes (notes text)

Workspace Pages (selected high-impact)

File onSubmit navigates? Text input?
src/pages/workspace/WorkspaceNamePage.tsx Yes (Navigation.goBack()) Yes (workspace name)
src/pages/workspace/WorkspaceOverviewDescriptionPage.tsx Yes (Navigation.goBack()) Yes (description, markdown)
src/pages/workspace/rules/RulesCustomPage.tsx Yes (Navigation.goBack()) Yes (custom rules, markdown)
src/pages/workspace/tags/WorkspaceCreateTagPage.tsx Yes (Navigation.goBack()) Yes (tag name)
src/pages/workspace/tags/EditTagPage.tsx Yes Yes (tag name)
src/pages/workspace/categories/CategoryForm.tsx Yes Yes (category name)
src/pages/workspace/taxes/WorkspaceCreateTaxPage.tsx Yes Yes (tax name/value)
src/pages/workspace/distanceRates/CreateDistanceRatePage.tsx Yes Yes (rate value)
src/pages/workspace/WorkspaceNewRoomPage.tsx Yes (creates report) Yes (room name)
src/pages/workspace/expensifyCard/WorkspaceEditCardNamePage.tsx Yes Yes (card name)
src/pages/workspace/members/WorkspaceInviteMessageComponent.tsx Yes Yes (invite message)
src/pages/workspace/reports/ReportsDefaultTitle.tsx Yes Yes (title)

There are many more workspace pages (rules amount pages, accounting integration pages, per diem pages, etc.) that follow the same pattern — roughly 50+ workspace form pages total.

Reimbursement Account / Bank Substeps

The ReimbursementAccount multi-step forms (both USD and NonUSD) also use FormProvider with onNext() that advances to the next substep. These are lower risk since many use pickers rather than text inputs, but substeps with text inputs (manual bank account entry, contact info, etc.) could be affected.

Summary

Total pages potentially affected: ~100+

The most visible to users would be:

  • IOU request steps (5-6 pages) — used every time someone creates/edits an expense
  • Profile/settings pages (6+ pages) — display name, phone, contact methods, status
  • Task pages (4 pages) — creating/editing tasks
  • Workspace configuration pages (50+ pages) — workspace names, tags, categories, rules, taxes, etc.

Recommendation

Given the scale, it may be worth considering whether the default behavior of FormProvider should be changed for forms that navigate on submit, rather than adding keyboardSubmitBehavior to each page individually. Options:

  1. Current approach (per-page opt-in): Each page that navigates on submit adds keyboardSubmitBehavior with platform-specific files — safe but requires touching 100+ pages
  2. Invert the default: Change the default to submit-and-dismiss / submit-only and only use dismiss-then-submit for forms that stay on screen — fewer changes but higher risk of regressions
  3. Detect navigation in FormProvider: If FormProvider could detect that onSubmit triggers navigation, it could automatically choose the right behavior — most elegant but most complex

This analysis was generated by MelvinBot based on code pattern analysis of the Expensify/App codebase.

@parasharrajat
Copy link
Member

@ikevin127 Do you agree with changing the default behaviour?

@parasharrajat
Copy link
Member

BUG: WEB: Enter to submit does not work.

Steps:

  1. Open description on any expense,
  2. enter some text to description field.
  3. PRess enter key on keyboard.

Expected: date should submit and page should close.

@ikevin127
Copy link
Contributor Author

ikevin127 commented Mar 8, 2026

@ikevin127 Do you agree with changing the default behaviour?

Given the number of components listed by Melvin, I think changing the behaviour at the FormProvider level risks tens or regressions throughout the app - and it would increase the testing scope of the PR significantly - which I'm not comfortable with, and if we stil decide to proceed, I'm sure we would have many uncaught regressions and probably multiple reverts / reworks.

cc @Julesssss for context - what do you think about Melvin's breakdown ?


BUG: WEB: Enter to submit does not work.

I'll get to this sometime by the EOW next week when I'll be back at full capacity 🙏

@Julesssss
Copy link
Contributor

Julesssss commented Mar 9, 2026

Hmm yeah that is a lot of changes. Lets stick with the fix for the case we noticed for now..

I do think we should look into modifying the default, it's a lot of effort either way but that seems the better choice. But we can look into that separately if you are interested in that work @parasharrajat?

@parasharrajat
Copy link
Member

I am happy to review that, but I won't be able to work on it currently. @Julesssss

@parasharrajat
Copy link
Member

Moving ahead with fix for this page.

@parasharrajat
Copy link
Member

Screenshots

🔲 iOS / native

🔲 iOS / Safari

🔲 MacOS / Chrome

🔲 Android / Chrome

🔲 Android / native

@ikevin127
Copy link
Contributor Author

🔄 Merged main as this was about 2k commits behind even though it had no conflicts.

BUG: WEB: Enter to submit does not work.

@parasharrajat Do you mind on confirming that this BUG does not exist on staging ? Asking because the web version of the dismissKeyboardAndExecute was not touched by me in this PR.

I wasn't able to reproduce on my machine at all, but I see the part of the logic that could cause this (dismissKeyboardAndExecute is synchronous on web) so in order to attempt a resolve for this I went with a solution that slightly changes the web version of dismissKeyboardAndExecute to be asynchronous using a microtask (Promise).

The two versions (before and after my change) might look similar because they both return a Promise, but they behave fundamentally differently in terms of when the callback cb() is actually executed.

Here's how the previous version - synchronous - (untouched by this PR):

const dismissKeyboardAndExecute = (cb: () => void): Promise<void> => {
    return new Promise((resolve) => {
        // This fixes a bug specific to native apps on Android < 16
        // For web it just executes callback
        // https://github.com/Expensify/App/issues/70692
        cb();
        resolve();
    });
};

How it works: In JavaScript, the "executor" function passed to new Promise runs synchronously.
The Problem: When we call dismissKeyboardAndExecute, the callback cb() is executed in the same execution tick as the "Enter" key press. Because React state updates (like the text we just typed) are asynchronous, the form submission logic (cb) often runs before React has finished updating the state. This causes the form to submit with "stale" or empty data.

and the slight change added by me - asynchronous / microtask - in hopes it would address the BUG you found:

const dismissKeyboardAndExecute = (cb: () => void): Promise<void> => {
    // This fixes a bug specific to native apps on Android < 16
    // For web it just executes callback
    // https://github.com/Expensify/App/issues/70692
    return Promise.resolve().then(cb);
};

How it works: When we use .then(), the callback is scheduled to run in the microtask queue.
The Fix: This forces the callback to wait until the current execution block (the "Enter" key event) is finished. This small delay gives React the chance to "flush" its pending state updates. By the time cb() runs in the next microtask:

  • The text input state is fully synced
  • Validation logic sees the latest values
  • The submission succeeds instead of failing due to stale data

@parasharrajat Let me know if this fixes the issue on your side (since I wasn't able to reproduce it on my side).

@ikevin127

This comment was marked as resolved.

@ikevin127
Copy link
Contributor Author

@parasharrajat 🟢 Merged main once again, resolved conflicts and all checks are passing.

@parasharrajat
Copy link
Member

Thanks.

@parasharrajat
Copy link
Member

Let me check it again.

@parasharrajat
Copy link
Member

I tried a few different times , and I don't see that button sliding down while the page is being closed. So this approach is probably not working.

15.03.2026_19.50.47_REC.mp4

@ikevin127
Copy link
Contributor Author

@parasharrajat I don't remember the requirement of "button sliding down while the page is being closed", mind clarifying where we discussed this as a must ?

From my context, the idea was to not delay the button until the keyboard is closed, which on Android was leaving the button stuck mid-screen while keyboard was closed, then the screen would be dismissed.

This PRs change removes such delays and dismisses the screen (slides to right) at the same time with the keyboard (slides down). The video above fulfils this which makes it expected behaviour IMO.

@Julesssss For context, please let us know what you think about this 🙌

@parasharrajat
Copy link
Member

parasharrajat commented Mar 17, 2026

Yeah, we didn't discuss that specifically, but I thought that this PR will work that way.

From my context, the idea was to not delay the button until the keyboard is closed, which on Android was leaving the button stuck mid-screen while keyboard was closed, then the screen would be dismissed.

For this, PR is working fine. Yeah, let's confirm with Jules here.

@Julesssss
Copy link
Contributor

For this, PR is working fine. Yeah, let's confirm with Jules here.

Yeah, we didn't discuss that specifically, but I thought that this PR will work that way.

I also thought that, but seeing it in action I think it looks good when closing the page 👍

@parasharrajat
Copy link
Member

parasharrajat commented Mar 18, 2026

Screenshots

🔲 iOS / native

18.03.2026_15.36.37_REC.mp4

🔲 iOS / Safari

18.03.2026_15.38.41_REC.mp4

🔲 MacOS / Chrome

18.03.2026_09.00.39_REC.mp4

🔲 Android / native

18.03.2026_08.58.54_REC.mp4

Copy link
Member

@parasharrajat parasharrajat left a comment

Choose a reason for hiding this comment

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

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 shown in the product is localized by adding it to src/languages/* files and using the translation method
    • I verified all numbers, amounts, dates and phone numbers shown in the product are using the localization methods
    • 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)
    • I verified proper file naming conventions were followed for any new files or renamed files. All non-platform specific files are named after what they export and are not named "index.js". All platform-specific files are named for the platform the code supports as outlined in the README.
    • I verified the JSDocs style guidelines (in STYLE.md) were followed
  • 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)
  • I verified all code is DRY (the PR doesn't include any logic written more than once, with the exception of tests)
  • I verified any variables that can be defined as constants (ie. in CONST.ts or at the top of the file that uses the constant) are defined as such
  • 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.
  • If a new page is added, I verified it's using the ScrollView component to make it scrollable when more elements are added to the page.
  • 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.

🎀 👀 🎀 C+ reviewed

@melvin-bot melvin-bot bot requested a review from Julesssss March 18, 2026 10:09
@Julesssss Julesssss merged commit e782e95 into Expensify:main Mar 19, 2026
32 checks passed
@github-actions
Copy link
Contributor

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

@github-actions
Copy link
Contributor

🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
Built from App PR #82536.

Android 🤖 iOS 🍎
❌ FAILED ❌ https://ad-hoc-expensify-cash.s3.us-east-1.amazonaws.com/rock-artifacts/ad-hoc/rock-ios-device-AdHoc-e782e95-c628576-961e83ec63718b95d7cbda7d0da7981acf939e0d/index.html
The QR code can't be generated, because the Android build failed iOS
Web 🕸️
https://82536.pr-testing.expensify.com
Web

👀 View the workflow run that generated this build 👀

@OSBotify
Copy link
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
Contributor

🚀 Deployed to staging by https://github.com/Julesssss in version: 9.3.41-0 🚀

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

Bundle Size Analysis (Sentry):

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/cristipaval in version: 9.3.41-4 🚀

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

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.

5 participants