You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Due for payment 2026-07-23] [INP] Slow Form-SubmitButton #85596
In an effort to improve the #quality of our app we started looking at INP (interaction to next pain) and looking at our slowest INPs we have [data-sentry-label=“Form-SubmitButton”]
Let's investigate why it is slow and fix it.
Issue OwnerCurrent Issue Owner: @rojiphilUpwork Automation - Do Not Edit
Please re-state the problem that we are trying to solve in this issue.
The interaction tagged as Form-SubmitButton has high INP. When a user taps submit while focused in a form field, the submit path feels delayed before the form transitions into the submit/loading flow.
What is the root cause of that problem?
In FormProvider.submit(), we currently wait for KeyboardUtils.dismiss() to resolve before calling onSubmit.
When the keyboard is visible, dismiss() resolves only after keyboard-hide events/viewport resize handling, so submit kickoff is blocked behind keyboard dismissal instead of starting immediately.
Assumption: on web, clicking submit can also trigger input blur validation and then full submit validation in the same interaction window, adding extra main-thread work around the same tap.
What changes do you think we should make in order to solve the problem?
In FormProvider.submit(), replace KeyboardUtils.dismiss().then(() => onSubmit(values)) with KeyboardUtils.dismissKeyboardAndExecute(() => onSubmit(values)).
Make submit-click blur prevention the default for forms (shouldPreventDefaultFocusOnPressSubmit = true in FormProvider/FormWrapper) so a submit click does not trigger an extra blur validation pass before submit.
Add a small submit-path performance measurement (validate time vs submit kickoff time) behind the same submit label so we can verify the INP drop after deployment.
What alternative solutions did you explore? (Optional)
I considered only optimizing individual forms that appear in Sentry traces, but this is a shared form-submit path used widely, so a central fix in FormProvider is safer and gives broader impact.
I also considered deferring validation with timers/idle callbacks, but that would delay error feedback and create inconsistent behavior across platforms.
Please re-state the problem that we are trying to solve in this issue.
The Form-SubmitButton interaction has a high INP score (>500ms at p75). When users tap submit on any form, the browser blocks painting for too long before showing visual feedback, creating a sluggish feel.
What is the root cause of that problem?
The submit handler in FormProvider.tsx performs multiple synchronous blocking operations before yielding to the browser:
onValidate → errors → onValidate dependency cycle: onValidate (line ~144) includes errors in its dependency array (line 205). Each validation call may setErrors, which changes errors, which recreates onValidate, which recreates submit, which recreates registerInput — causing all form inputs to re-render in a cascade before the next paint.
Synchronous validation in submit path: submit (line ~255) calls onValidate(trimmedStringValues) synchronously and checks its return inline. The validation iterates all input values, runs prepareValues (string trimming), performs HTML tag regex matching on every field, and calls setErrors — all blocking the main thread during the press event.
registerInput recreated too often: It depends on errors, inputValues, draftValues, formState?.errorFields, onValidate, and submit (line ~460). Any change to any of these triggers a new callback, forcing every registered input to receive new props and re-render.
Un-memoized FormAlertWithSubmitButton: It is a plain function component (no React.memo), so it re-renders every time FormWrapper re-renders, even when its own props are unchanged.
withNavigationFallback HOC on Button: Every Button render goes through this un-memoized HOC layer (line 551 of Button/index.tsx), adding overhead via the useIsFocused() hook.
What changes do you think we should make in order to solve the problem?
Break the onValidate → errors cycle: Replace errors in onValidates dependency array with a ref (errorsRef.current). Validation only needs the current error values for comparison, not reactivity — a ref avoids the cascade.
Defer validation off the critical path: Wrap the onValidate call inside submit with InteractionManager.runAfterInteractions() so the button press visual feedback paints first, then validation runs. Show immediate visual feedback (loading state) before starting validation.
Wrap FormAlertWithSubmitButton in React.memo and stabilize its callback props (onSubmit, onFixTheErrorsLinkPressed) with useCallback in FormWrapper.
Memoize the SubmitButton JSX in FormWrapper using useMemo instead of the current inline const SubmitButton = isSubmitButtonVisible && (...) which creates a new element tree every render.
Stabilize registerInput by moving inputValues and errors reads to refs where they are only used for current-value lookups, not as reactive dependencies.
What alternative solutions did you explore? (Optional)
Using startTransition from React 18 was considered but INP measures time to next paint, and startTransition still blocks the main thread — it just marks the update as non-urgent for React scheduler, which does not help with INP.
Moving validation to a Web Worker was considered but impractical since it needs access to React state and Onyx stores.
📣 @mendarb! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
📣 @czarflix! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Get the email address used to login to your Expensify account. If you don't already have an Expensify account, create one here. If you have multiple accounts (e.g. one for testing), please use your main account email.
Get the link to your Upwork profile. It's necessary because we only pay via Upwork. You can access it by logging in, and then clicking on your name. It'll look like this. If you don't already have an account, sign up for one here.
Copy the format below and paste it in a comment on this issue. Replace the placeholder text with your actual details.
Format:
Contributor details
Your Expensify account email: <REPLACE EMAIL HERE>
Upwork Profile Link: <REPLACE LINK HERE>
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: Skipping the link as this is an improvement feature
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: Not Required. The existing checklist is good enough to capture such issues.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
If there are posts on the PR or issue that reference a regression or deploy blocker, C+ posts on the issue and confirms regression (which will reduce pay by 50%) or provides reasoning why they shouldn’t be considered. If the C+ doesn’t update the issue, the contributor manager making the payment will assume any mention of a regression or deploy blockers reduces the issue amount.
Ah yes! Agree that there were regressions here. @rlinoz Due to the nature of the improvement added here, there were already quite a lot of use cases covered in testing, which required more time than what we regularly take for a default compensation. So, although I agree that we missed some additional edge cases which were covered later via regression fixes, can we go ahead with the default compensation here considering the vast coverage area of test cases?
The implementation in #92498 introduced the stuck Save state reported in #99152. It was fixed in #99344 by opting the Travel Billing monthly-limit form out of immediate press loading.
Activity
melvin-bot commentedon Mar 17, 2026
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ShridharGoel (
External)[-][INP] Slow Form-SubmitButton[/-][+][$250] [INP] Slow Form-SubmitButton[/+]melvin-bot commentedon Mar 17, 2026
Job added to Upwork: https://www.upwork.com/jobs/~022034008884287958380
MelvinBot commentedon Mar 17, 2026
I have failed to help you. I let you down and for that I am sorry. Please try again later. This may be due to a Claude outage (check here).
Failure details: https://github.com/Expensify/Expensify/actions/runs/23215718760
jainam884 commentedon Mar 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
The interaction tagged as
Form-SubmitButtonhas high INP. When a user taps submit while focused in a form field, the submit path feels delayed before the form transitions into the submit/loading flow.What is the root cause of that problem?
In
FormProvider.submit(), we currently wait forKeyboardUtils.dismiss()to resolve before callingonSubmit.App/src/components/Form/FormProvider.tsx
Lines 236 to 266 in 858f99c
When the keyboard is visible,
dismiss()resolves only after keyboard-hide events/viewport resize handling, so submit kickoff is blocked behind keyboard dismissal instead of starting immediately.App/src/utils/keyboard/index.ts
Lines 23 to 38 in 858f99c
App/src/utils/keyboard/index.website.ts
Lines 37 to 67 in 858f99c
Assumption: on web, clicking submit can also trigger input blur validation and then full submit validation in the same interaction window, adding extra main-thread work around the same tap.
What changes do you think we should make in order to solve the problem?
FormProvider.submit(), replaceKeyboardUtils.dismiss().then(() => onSubmit(values))withKeyboardUtils.dismissKeyboardAndExecute(() => onSubmit(values)).shouldPreventDefaultFocusOnPressSubmit = trueinFormProvider/FormWrapper) so a submit click does not trigger an extra blur validation pass before submit.What alternative solutions did you explore? (Optional)
I considered only optimizing individual forms that appear in Sentry traces, but this is a shared form-submit path used widely, so a central fix in
FormProvideris safer and gives broader impact.I also considered deferring validation with timers/idle callbacks, but that would delay error feedback and create inconsistent behavior across platforms.
mendarb commentedon Mar 17, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
The Form-SubmitButton interaction has a high INP score (>500ms at p75). When users tap submit on any form, the browser blocks painting for too long before showing visual feedback, creating a sluggish feel.
What is the root cause of that problem?
The submit handler in
FormProvider.tsxperforms multiple synchronous blocking operations before yielding to the browser:onValidate→errors→onValidatedependency cycle:onValidate(line ~144) includeserrorsin its dependency array (line 205). Each validation call maysetErrors, which changeserrors, which recreatesonValidate, which recreatessubmit, which recreatesregisterInput— causing all form inputs to re-render in a cascade before the next paint.Synchronous validation in submit path:
submit(line ~255) callsonValidate(trimmedStringValues)synchronously and checks its return inline. The validation iterates all input values, runsprepareValues(string trimming), performs HTML tag regex matching on every field, and callssetErrors— all blocking the main thread during the press event.registerInputrecreated too often: It depends onerrors,inputValues,draftValues,formState?.errorFields,onValidate, andsubmit(line ~460). Any change to any of these triggers a new callback, forcing every registered input to receive new props and re-render.Un-memoized
FormAlertWithSubmitButton: It is a plain function component (noReact.memo), so it re-renders every time FormWrapper re-renders, even when its own props are unchanged.withNavigationFallbackHOC on Button: Every Button render goes through this un-memoized HOC layer (line 551 of Button/index.tsx), adding overhead via theuseIsFocused()hook.What changes do you think we should make in order to solve the problem?
Break the
onValidate→errorscycle: ReplaceerrorsinonValidates dependency array with a ref (errorsRef.current). Validation only needs the current error values for comparison, not reactivity — a ref avoids the cascade.Defer validation off the critical path: Wrap the
onValidatecall insidesubmitwithInteractionManager.runAfterInteractions()so the button press visual feedback paints first, then validation runs. Show immediate visual feedback (loading state) before starting validation.Wrap
FormAlertWithSubmitButtoninReact.memoand stabilize its callback props (onSubmit,onFixTheErrorsLinkPressed) withuseCallbackin FormWrapper.Memoize the SubmitButton JSX in FormWrapper using
useMemoinstead of the current inlineconst SubmitButton = isSubmitButtonVisible && (...)which creates a new element tree every render.Stabilize
registerInputby movinginputValuesanderrorsreads to refs where they are only used for current-value lookups, not as reactive dependencies.What alternative solutions did you explore? (Optional)
startTransitionfrom React 18 was considered but INP measures time to next paint, andstartTransitionstill blocks the main thread — it just marks the update as non-urgent for React scheduler, which does not help with INP.melvin-bot commentedon Mar 17, 2026
📣 @mendarb! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
czarflix commentedon Mar 18, 2026
I’m working on reproducing this on staging, will update shortly.
melvin-bot commentedon Mar 18, 2026
📣 @czarflix! 📣
Hey, it seems we don’t have your contributor details yet! You'll only have to do this once, and this is how we'll hire you on Upwork.
Please follow these steps:
Format:
109 remaining items
rojiphil commentedon Jul 23, 2026
BugZero Checklist:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: Skipping the link as this is an improvement feature
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: Not Required. The existing checklist is good enough to capture such issues.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue: https://github.com/Expensify/Expensify/issues/664870
Regression Test Proposal
Precondition:
Test:
Account > Profile > Display name
Account > Profile > Contact method (or Workspace > Profile > Name)
Group chat > Invite participant
Room > Invite member
Expense report > Change approver > Add approver
Report > Create task
Settings > Rules (personal rule)
Go to Workspace > Rules > Merchant rules > create/edit a rule.
Go to Workspace > Rules > Spend rules > add/edit a rule > Choose cards.
Go to Workspace > Rules > Spend rules > add/edit a rule.
Go to Workspace > Rules > Spend rules > add/edit a rule > Spend category.
Go to Workspace > Rules > Spend rules > add/edit a rule > Merchants.
Workspace > Workflows > Create workflow
Workspace > Workflows > Edit workflow
Workspace > Workflows > Expenses from
Workspace > Members > Invite member
Workspace > Company cards > Settings > Statement close date
Go to Workspace > Company cards > Assign card > select assignee > Card selection.
Account > Domains > Admins > Invite
Account > Wallet > Add bank account > Bank account purpose
Account > Wallet > Report virtual card fraud
Sign-in > Login form
Additional Card Scenarios
Precondition:
Workspace has at least one Expensify Card.
Steps:
Steps:
Do we agree 👍 or 👎
Zapier Logs
Run ID: 00040eee-38af-ae3b-e62b-0d1afcbe9404mallenexpensify commentedon Jul 27, 2026
@rojiphil from the C+ doc
^ Test case created. Thx
rojiphil commentedon Jul 27, 2026
Ah yes! Agree that there were regressions here.
@rlinoz Due to the nature of the improvement added here, there were already quite a lot of use cases covered in testing, which required more time than what we regularly take for a default compensation. So, although I agree that we missed some additional edge cases which were covered later via regression fixes, can we go ahead with the default compensation here considering the vast coverage area of test cases?
rlinoz commentedon Jul 27, 2026
Yes, I think it is fair. We touched a lot of different paths with this change and the edge cases were minor.
rojiphil commentedon Jul 27, 2026
Thanks @rlinoz.
@mallenexpensify Over to you now for the payment summary here based on #85596 (comment) and #85596 (comment). Thanks.
mallenexpensify commentedon Jul 27, 2026
Payment Summary
Contributor+: @rojiphil due $250 via NewDot
Thx for the detailed explanation, thanks @rlinoz for confirming
nyomanjyotisa commentedon Aug 28, 2026
The implementation in #92498 introduced the stuck Save state reported in #99152. It was fixed in #99344 by opting the Travel Billing monthly-limit form out of immediate press loading.
quinthar commentedon Sep 2, 2026
Approved $250 to @rojiphil