Skip to content

Introduce the spinner on the FormAlertWithSubmitButton buttons - #92498

Merged
rlinoz merged 30 commits into
Expensify:mainfrom
software-mansion-labs:@OlGierd03/Form-SubmitButton-button-spinner
Jul 13, 2026
Merged

rlinoz merged 30 commits into
Expensify:mainfrom
software-mansion-labs:@OlGierd03/Form-SubmitButton-button-spinner

Conversation

@OlGierd03

@OlGierd03 OlGierd03 commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Explanation of Change

A spinner has been added to the buttons in FormAlertWithSubmitButton to improve responsiveness for users and thus reduce the INP metric for interactions labelled [data-sentry-label="Form-SubmitButton"].

A loading spinner now appears on vast majority of the FormAlertWithSubmitButton buttons the instant the button is pressed, before onSubmit or any loading state driven by Onyx. These changes add a shared usePressLoading hook that holds the logic for showing a spinner immediately on press. The instant spinner is on by default through a new shouldShowLoadingImmediatelyOnPress prop that defaults to true. Gatekeepers that validate before submitting, such as FormProvider with FormWrapper and BaseLoginForm, opt out and drive the spinner themselves through the same hook. Some consumers who make early returns via onSubmit with state-only change have also been excluded.

Under the hood a press flips a local isPressed flag to true and the actual work is wrapped in setTimeout(…,0). Deferring by one macrotask lets React commit isPressed=true and paint the spinner before consumer code that may block the JS thread runs. isPressed then resets on the next tick and hands the loading state over to the consumer's real isLoading, which is usually driven by Onyx. If validation or violations short circuit the submit and isLoading never turns true the spinner cancels itself naturally.

The navigate forward case needs special handling. When onSubmit pushes a new screen on top of the current one the current screen stays mounted so a local loading flag would never reset and the spinner would stay stuck on return. Those screens (such as DynamicWorkspaceInvitePage) clear the flag when the screen regains focus through useEffectFocus.

Fixed Issues

$ #85596

Tests

FormProvider

Account > Profile > Display name

  1. Go to Account (bottom tab) > Profile > Display name.
  2. Change the first name and press Save.
  3. Verify the spinner appears on Save the instant it is pressed (before the value persists) and the form saves correctly.
  4. Reopen the form, clear a required field and press Save.
  5. Verify the validation error shows and the spinner does NOT stay stuck (it cancels on violations).
  6. Rapidly double-press Save on a valid form.
  7. Verify the form is submitted only once (no duplicate request).

Account > Profile > Contact method (or Workspace > Profile > Name)

  1. Open the form, enter a valid value and press the submit button.
  2. Verify the spinner appears immediately on press and the form submits correctly (confirms the behavior is global to the Form framework).
Reports / Chat / Tasks

Group chat > Invite participant

  1. Open a group chat > tap the header > Members > Invite member.
  2. Select a member and press Invite, then immediately press Back.
  3. Verify there is no stuck spinner on Invite and the button is pressable again.

Room > Invite member

  1. Open a workspace room > tap the header > Members > Invite member.
  2. Select a member and press Invite, then immediately press Back.
  3. Verify there is no stuck spinner on Invite and the button is pressable again.

Expense report > Change approver > Add approver

  1. Open an expense report > Report details > Change approver > Add approver.
  2. Select an approver and press Save, then immediately press Back.
  3. Verify there is no stuck spinner on Save and the button is pressable again.

Report > Create task

  1. Open a report > compose menu (+) > Assign task, fill in the details.
  2. Press Confirm task, then immediately press Back.
  3. Verify there is no stuck spinner on Confirm task and the button is pressable again.
Workspace - Rules

Settings > Rules (personal rule)

  1. Go to Account > Settings > Rules > create/edit a rule.
  2. Press Save rule.
  3. Verify the spinner shows immediately and clears.

Workspace > Rules > Merchant rules

  1. Go to Workspace > Rules > Merchant rules > create/edit a rule.
  2. Press Save rule.
  3. Verify the spinner shows immediately and clears.

Workspace > Rules > Spend rules > Choose cards

  1. Go to Workspace > Rules > Spend rules > add/edit a rule > Choose cards.
  2. Select cards and press Save/Confirm.
  3. Verify the spinner shows immediately and clears.

Workspace > Rules > Spend rules (rule config)

  1. Go to Workspace > Rules > Spend rules > add/edit a rule.
  2. Press Save rule.
  3. Verify the spinner shows immediately and clears.

Workspace > Rules > Spend rules > Spend category

  1. Go to Workspace > Rules > Spend rules > add/edit a rule > Spend category.
  2. Select categories and press Save.
  3. Verify the spinner shows immediately and clears.

Workspace > Rules > Spend rules > Merchants

  1. Go to Workspace > Rules > Spend rules > add/edit a rule > Merchants.
  2. Add a merchant and press Save.
  3. Verify the spinner shows immediately on Save and clears.
Workspace - Workflows

Workspace > Workflows > Create workflow

  1. Go to Workspace > Workflows > Create workflow, configure approvers.
  2. Press Add workflow, then immediately press Back.
  3. Verify there is no stuck spinner and the button is pressable again.

Workspace > Workflows > Edit workflow

  1. Go to Workspace > Workflows > open an existing workflow.
  2. Press Save, then immediately press Back.
  3. Verify there is no stuck spinner and the button is pressable again.

Workspace > Workflows > Expenses from

  1. Go to Workspace > Workflows > Create workflow > "Expenses from".
  2. Select members and press Next.
  3. Verify the spinner shows immediately on press.
Workspace - Members & Company cards

Workspace > Members > Invite member

  1. Go to Account > Workspaces > select a workspace > Members > Invite member.
  2. Select a member and press Next.
  3. Verify the spinner shows immediately on press.

Workspace > Company cards > Settings > Statement close date

  1. Go to Workspace > Company cards > Settings > Statement close date.
  2. Pick a date and press Save/Confirm, then immediately press Back.
  3. Verify there is no stuck spinner and the button is pressable again.

Workspace > Company cards > Assign card > Card selection

  1. Go to Workspace > Company cards > Assign card > select assignee > Card selection.
  2. Select a card and press Next/Confirm, then immediately press Back.
  3. Verify there is no stuck spinner and the button is pressable again.
Domain / Wallet / Sign-in

Account > Domains > Admins > Invite

  1. Go to Account > Domains > select a domain > Admins > Invite.
  2. Select a user and press Invite, then immediately press Back.
  3. Verify there is no stuck spinner and the button is pressable again.

Account > Wallet > Add bank account > Bank account purpose

  1. Go to Account > Wallet > Add bank account > Bank account purpose.
  2. Select a country and press Next, then immediately press Back.
  3. Verify there is no stuck spinner and the button is pressable again.

Account > Wallet > Report virtual card fraud

  1. Go to Account > Wallet > open an Expensify virtual card > Report fraud.
  2. Press Deactivate card.
  3. Verify the spinner shows immediately on press and the card deactivates.

Sign-in > Login form

  1. From the logged-out screen, enter an email and press Continue.
  2. Verify there is no stuck spinner on Continue if you return to the login form.

Offline tests

NA

QA Steps

Same as tests

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 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: mWeb Chrome
iOS: Native
Screen.Recording.2026-06-16.at.14.00.51.mov
Screen.Recording.2026-06-16.at.14.05.25.mov
Screen.Recording.2026-06-16.at.14.13.08.mov
Screen.Recording.2026-06-16.at.14.14.08.mov
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-06-08.at.14.41.15.mov
A1.mov
A5.mov
B3.mov
2.mov
4.mov
5.mov
6.mov

@melvin-bot

melvin-bot Bot commented Jun 3, 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!

@OlGierd03

Copy link
Copy Markdown
Contributor Author

@codex review

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

Copy link
Copy Markdown

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: 141c0b8843

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

@codecov

codecov Bot commented Jun 10, 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/components/Form/FormWrapper.tsx 82.35% <ø> (ø)
src/components/FormAlertWithSubmitButton.tsx 97.14% <100.00%> (+0.47%) ⬆️
...ings/Security/MergeAccounts/AccountDetailsPage.tsx 0.00% <ø> (ø)
...nkAccountPurposePage/substeps/CountrySelection.tsx 60.00% <100.00%> (+1.17%) ⬆️
src/pages/signin/LoginForm/BaseLoginForm.tsx 76.92% <ø> (ø)
...ayments/Wallet/FeesAndTerms/substeps/TermsStep.tsx 0.00% <0.00%> (ø)
...ard/issueNew/spendRules/SpendRuleSelectionPage.tsx 0.00% <0.00%> (ø)
...s/workspace/rules/SpendRules/SpendRuleCardPage.tsx 0.00% <0.00%> (ø)
...pprovals/WorkspaceWorkflowsApprovalsCreatePage.tsx 0.00% <0.00%> (ø)
...ponents/Search/FilterComponents/DateFilterBase.tsx 69.84% <33.33%> (-1.83%) ⬇️
... and 17 more
... and 13 files with indirect coverage changes

@OlGierd03 OlGierd03 changed the title Introduce the spinner on the button in FormAlertWithSubmitButton Introduce the spinner on the FormAlertWithSubmitButton buttons Jun 11, 2026
@OlGierd03

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: 4920f97d43

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

@JakubKorytko JakubKorytko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Some comments, otherwise LGTM

Comment thread src/pages/tasks/NewTaskPage.tsx Resolved
Comment thread src/hooks/usePressLoading.ts Resolved
Comment thread src/components/Form/FormWrapper.tsx Resolved
Comment thread src/hooks/usePressLoading.ts Resolved
Comment thread src/hooks/usePressLoading.ts Resolved
Comment thread src/hooks/usePressLoading.ts Resolved
Comment thread src/hooks/usePressLoading.ts Resolved
Comment thread src/hooks/usePressLoading.ts Resolved
Comment thread src/components/Form/FormWrapper.tsx Resolved
OlGierd03 and others added 2 commits June 22, 2026 12:09
Co-authored-by: dariusz-biela <26382728+dariusz-biela@users.noreply.github.com>
@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to staging by https://github.com/rlinoz in version: 9.4.34-0 🚀

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

@MelvinBot

Copy link
Copy Markdown
Contributor

🤖 I reviewed the changes in this PR against Expensify's help site files under App/docs/articles.

No help site changes are required.

This PR is a UI responsiveness/performance improvement: it adds a loading spinner that appears the instant a FormAlertWithSubmitButton button is pressed (via the new usePressLoading hook and the shouldShowLoadingImmediatelyOnPress prop) to reduce the INP metric for Form-SubmitButton interactions.

It does not:

  • Introduce, rename, or remove any user-facing feature, setting, tab, or button label
  • Change any documented workflow, billing/pricing behavior, or integration
  • Alter any step a user follows to complete a task

The help site documents what users do and where they do it — this change only affects the visual feedback (a spinner) shown while an existing action is already in progress, which isn't behavior described in any article. Because there's nothing new or changed to document, I did not create a draft docs PR.

If you believe a specific article should call out this behavior, reply with the article and what you'd like added and I'll draft it.

@jponikarchuk

Copy link
Copy Markdown

Deploy Blocker #96055 was identified to be related to this PR.

@jponikarchuk

Copy link
Copy Markdown

Deploy Blocker #96058 was identified to be related to this PR.

@jponikarchuk

Copy link
Copy Markdown

This PR failing because of the issue #96058
This issue is reproducible in: Android app

@mitarachim

Copy link
Copy Markdown

Deploy Blocker #96072 was identified to be related to this PR.

@jponikarchuk

Copy link
Copy Markdown

Deploy Blocker #96088 was identified to be related to this PR.

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.34-14 🚀

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

@OSBotify

Copy link
Copy Markdown
Contributor

🚀 Deployed to production by https://github.com/roryabraham in version: 9.4.34-14 🚀

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

Bundle Size Analysis (Sentry):

@nyomanjyotisa

Copy link
Copy Markdown
Member

#92498 introduced immediate press loading in FormProvider. On the Travel Billing monthly-limit form, cancelling the reduction confirmation did not trigger an external loading state or navigation, so the Save button remained loading. This caused #99152 and was fixed in #99344.

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.