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
[HOLD #82586][$250] Expense - Amount input field loses focus #84960
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Version Number: v9.3.36-0 Reproducible in staging?: Yes Reproducible in production?: No If this was caught during regression testing, add the test name, ID and link from BrowserStack: N/A Email or phone of affected tester (no customers):testpayment935@gmail.com Issue reported by: Applause Internal Team Bug source: Exploratory - Critical User Impact Device used: Windows 11 pro /Chrome App Component: Money Requests
Action Performed:
Navigate to staging.new.expensify.com
FAB > Create Expense
Expected Result:
The amount input field doesn't lose focus
Actual Result:
Amount input field loses focus so unable to enter amount unless focusing again
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
Identify the pull request that introduced this issue and revert it.
Classification: Frontend bug Causing PR: #84780 - "[No QA] Revert "fix: Amount is out of view when max number of digits"" by @aimane-chnaif (High confidence) Related Issues: #81655 (original PR that was reverted)
Recommendation: REVERT
Revert PR #84780 to restore the previous behavior. While the revert was done to prevent a different bug from reaching staging, it introduced this focus loss regression.
Labels: No changes needed. This is correctly labeled as DeployBlockerCash (frontend bug). The fix requires reverting App PR #84780.
Detailed Analysis
Evidence
PR #84780 was merged on 2026-03-10 at 18:38:49Z, which is:
In the current staging deploy (v9.3.36-0)
Before the bug was reported (2026-03-11 at 20:51:34Z)
Not yet on production (bug is only reproducible on staging)
The PR reverted changes to src/components/NumberWithSymbolForm.tsx that added a useMemo hook for calculating dynamic font sizes based on amount length. The revert removed:
A useMemo hook that computed dynamicAmountStyle
The useStyleUtils hook
The getAmountInputFontSize utility function
Verification
The affected files are:
src/components/NumberWithSymbolForm.tsx - Core component for amount input
src/pages/iou/request/step/IOURequestStepAmount.tsx - The expense creation flow page
PR #84780 directly modifies NumberWithSymbolForm.tsx, which is the component responsible for rendering the amount input field in the expense creation flow.
Root Cause
When PR #81655 originally added the useMemo hook for dynamic styling, it likely introduced a different bug (shown in screenshot comment). The revert removed this memoization, but in doing so appears to have changed the component re-render behavior in a way that causes the input to lose focus.
The issue occurs because the style object reference changes on every render without memoization, which can trigger React to unmount/remount or blur/refocus the underlying TextInput component. This is particularly problematic in web browsers where DOM manipulation tied to style changes can interfere with focus state.
Please re-state the problem that we are trying to solve in this issue.
When navigating to FAB > Create Expense on staging (v9.3.36-0), the amount input field loses focus immediately, requiring the user to manually tap/click the input before they can enter an amount. This does not happen on production.
What is the root cause of that problem?
The root cause is PR #84286 (perf: optimize ManualOpenCreateExpense with policy selector and reduced subscriptions), which changed how selectedTab is managed in IOURequestStartPage.tsx.
Before PR #84286 (production):selectedTab was stored in React local state via useState(lastSelectedTab), with a useEffect to sync from Onyx. When OnyxTabNavigator wrote the initial tab value back to Onyx via Tab.setSelectedTab(), the useEffect in IOURequestStartPage would bail out because selectedTab was already truthy (set by the immediate setSelectedTab call in onTabSelected). This prevented the Onyx roundtrip from causing a re-render of the parent component.
After PR #84286 (staging):selectedTab is derived directly from the Onyx value (const selectedTab = lastSelectedTab at IOURequestStartPage.tsx:88). Now when OnyxTabNavigator writes the tab to Onyx on mount (OnyxTabNavigator.tsx:190), that write propagates back through useOnyx, causing IOURequestStartPage to re-render. Since selectedTab is used in several rendering-significant props — ScreenWrapper.shouldEnableMaxHeight (line 294), DragAndDropProvider.isDisabled (line 299), the transactionRequestType memo (line 153) — this triggers a cascade of child re-renders.
Meanwhile, IOURequestStepAmount has a useFocusEffect (IOURequestStepAmount.tsx:170-182) that schedules focus via a 400ms setTimeout. When the parent re-renders from the Onyx roundtrip during this window, the useFocusEffect cleanup fires and clears the pending focus timeout. If the component subtree re-mounts due to changed ScreenWrapper/DragAndDropProvider props, focus is permanently lost.
What changes do you think we should make in order to solve the problem?
Restore the local state buffer for selectedTab in IOURequestStartPage.tsx. Specifically, revert the selectedTab derivation back to using useState + useEffect to buffer the Onyx value, while keeping the other performance improvements from PR #84286 (the iouRequestPolicyCollectionSelector and the NVP selector for SCAN_TEST_TOOLTIP). The key change needed:
In IOURequestStartPage.tsx, replace const selectedTab = lastSelectedTab with a useState/useEffect pair that initializes from and syncs with lastSelectedTab, and restore setSelectedTab(newIouType) in the onTabSelected callback. This prevents the Onyx roundtrip from Tab.setSelectedTab() from triggering a re-render of the page during the initial mount sequence.
What alternative solutions did you explore? (Optional)
Increase the focus timeout in IOURequestStepAmount.tsx to exceed the Onyx roundtrip window. This is fragile and timing-dependent — not recommended.
Use useRef instead of direct derivation for selectedTab to avoid re-renders. This would work but is more complex than restoring the proven useState pattern.
Next Steps for Contributor+ team: Reply with @MelvinBot implement this to create a draft PR, @MelvinBot <your feedback> to refine this analysis, or explain why you are rejecting Melvin's proposal.
This issue has not been updated in over 15 days. @rlinoz, @ChavdaSachin eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
OnyxTabNavigator writes the selected tab back to the same Onyx key during its initial/tab state event via Tab.setSelectedTab(), then calls onTabSelected(). That callback runs useResetIOUType, which can call Keyboard.dismiss() and rebuild/update the draft transaction.
So the failing chain is:
FAB > Create Expense navigates through startMoneyRequest() to the create expense tab route.
The Manual amount tab renders and schedules focus.
OnyxTabNavigator persists the selected tab during the same mount/tab-selection window.
IOURequestStartPage receives that Onyx update and re-renders layout-affecting props such as ScreenWrapper.shouldEnableMaxHeight, DragAndDropProvider.isDisabled, and transactionRequestType.
useResetIOUType may also dismiss the keyboard and update the draft transaction.
This lands during/after the delayed focus window, so on web/Chrome the amount input briefly focuses and then blurs.
This is timing-sensitive, which explains why it can be intermittent and dependent on the existing persisted selected tab / draft transaction state.
What changes do you think we should make in order to solve the problem?
Restore a local selectedTab buffer in IOURequestStartPage instead of rendering directly from the Onyx value.
Specifically:
Initialize local state from lastSelectedTab.
Sync from Onyx only when the local selected tab is still empty and Onyx has finished loading.
In the onTabSelected callback, call setSelectedTab(newIouType) immediately before resetIOUTypeIfChanged(newIouType).
That keeps the tab UI stable during the initial Onyx roundtrip and prevents the parent create-expense page from re-rendering after the amount input’s delayed focus has already been scheduled.
As hardening, useResetIOUType should avoid dismissing the keyboard for no-op tab selections. The transaction?.iouRequestType === newIOUType guard should happen before Keyboard.dismiss(), because an initial tab state event that confirms the already-selected tab should not blur the active amount input.
Verification plan:
On web/Chrome, clear or change the persisted selectedTab_iouRequestType, then use FAB > Create Expense and land on/open the Manual amount tab.
Confirm the amount input remains focused and accepts typing immediately.
Repeat with a previously persisted Manual tab and with a stale Scan/Distance selected tab.
Add a focused test around IOURequestStartPage/OnyxTabNavigator verifying that the initial selected-tab Onyx write does not cause a post-focus blur/no-op keyboard dismiss for the amount step.
What alternative solutions did you explore? (Optional)
Increasing the amount-step focus timeout would only hide the race and would still be vulnerable to slower Onyx updates.
Forcing another focus from NumberWithSymbolForm or MoneyRequestAmountInput is also too narrow because the blur is caused by parent tab/Onyx state churn, not by amount formatting itself. The fix should stabilize the tab state boundary and avoid dismissing the keyboard on no-op tab initialization.
BugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributorHelp WantedApply this label when an issue is open to proposals by contributors
Activity
melvin-bot commentedon Mar 11, 2026
Triggered auto assignment to @rlinoz (
DeployBlockerCash), see https://stackoverflowteams.com/c/expensify/questions/9980/ for more details.melvin-bot commentedon Mar 11, 2026
💬 A slack conversation has been started in #expensify-open-source
github-actions commentedon Mar 11, 2026
👋 Friendly reminder that deploy blockers are time-sensitive ⏱ issues! Check out the open `StagingDeployCash` deploy checklist to see the list of PRs included in this release, then work quickly to do one of the following:
OSBotify commentedon Mar 11, 2026
Investigation Summary
Classification: Frontend bug
Causing PR: #84780 - "[No QA] Revert "fix: Amount is out of view when max number of digits"" by @aimane-chnaif (High confidence)
Related Issues: #81655 (original PR that was reverted)
Recommendation: REVERT
Revert PR #84780 to restore the previous behavior. While the revert was done to prevent a different bug from reaching staging, it introduced this focus loss regression.
Labels: No changes needed. This is correctly labeled as
DeployBlockerCash(frontend bug). The fix requires reverting App PR #84780.Detailed Analysis
Evidence
PR #84780 was merged on 2026-03-10 at 18:38:49Z, which is:
The PR reverted changes to
src/components/NumberWithSymbolForm.tsxthat added auseMemohook for calculating dynamic font sizes based on amount length. The revert removed:useMemohook that computeddynamicAmountStyleuseStyleUtilshookgetAmountInputFontSizeutility functionVerification
The affected files are:
src/components/NumberWithSymbolForm.tsx- Core component for amount inputsrc/pages/iou/MoneyRequestAmountForm.tsx- Wraps NumberWithSymbolFormsrc/pages/iou/request/step/IOURequestStepAmount.tsx- The expense creation flow pagePR #84780 directly modifies
NumberWithSymbolForm.tsx, which is the component responsible for rendering the amount input field in the expense creation flow.Root Cause
When PR #81655 originally added the
useMemohook for dynamic styling, it likely introduced a different bug (shown in screenshot comment). The revert removed this memoization, but in doing so appears to have changed the component re-render behavior in a way that causes the input to lose focus.The issue occurs because the style object reference changes on every render without memoization, which can trigger React to unmount/remount or blur/refocus the underlying TextInput component. This is particularly problematic in web browsers where DOM manipulation tied to style changes can interfere with focus state.
vincdargento commentedon Mar 11, 2026
The culprit PR must be #84448 (snapshot build not generated, so can't test on this one) or #84452
MelvinBot commentedon Mar 11, 2026
Proposal
Please re-state the problem that we are trying to solve in this issue.
When navigating to FAB > Create Expense on staging (v9.3.36-0), the amount input field loses focus immediately, requiring the user to manually tap/click the input before they can enter an amount. This does not happen on production.
What is the root cause of that problem?
The root cause is PR #84286 (
perf: optimize ManualOpenCreateExpense with policy selector and reduced subscriptions), which changed howselectedTabis managed inIOURequestStartPage.tsx.Before PR #84286 (production):
selectedTabwas stored in React local state viauseState(lastSelectedTab), with auseEffectto sync from Onyx. WhenOnyxTabNavigatorwrote the initial tab value back to Onyx viaTab.setSelectedTab(), theuseEffectinIOURequestStartPagewould bail out becauseselectedTabwas already truthy (set by the immediatesetSelectedTabcall inonTabSelected). This prevented the Onyx roundtrip from causing a re-render of the parent component.After PR #84286 (staging):
selectedTabis derived directly from the Onyx value (const selectedTab = lastSelectedTabatIOURequestStartPage.tsx:88). Now whenOnyxTabNavigatorwrites the tab to Onyx on mount (OnyxTabNavigator.tsx:190), that write propagates back throughuseOnyx, causingIOURequestStartPageto re-render. SinceselectedTabis used in several rendering-significant props —ScreenWrapper.shouldEnableMaxHeight(line 294),DragAndDropProvider.isDisabled(line 299), thetransactionRequestTypememo (line 153) — this triggers a cascade of child re-renders.Meanwhile,
IOURequestStepAmounthas auseFocusEffect(IOURequestStepAmount.tsx:170-182) that schedules focus via a 400mssetTimeout. When the parent re-renders from the Onyx roundtrip during this window, theuseFocusEffectcleanup fires and clears the pending focus timeout. If the component subtree re-mounts due to changed ScreenWrapper/DragAndDropProvider props, focus is permanently lost.What changes do you think we should make in order to solve the problem?
Restore the local state buffer for
selectedTabinIOURequestStartPage.tsx. Specifically, revert theselectedTabderivation back to usinguseState+useEffectto buffer the Onyx value, while keeping the other performance improvements from PR #84286 (theiouRequestPolicyCollectionSelectorand the NVP selector forSCAN_TEST_TOOLTIP). The key change needed:IOURequestStartPage.tsx, replaceconst selectedTab = lastSelectedTabwith auseState/useEffectpair that initializes from and syncs withlastSelectedTab, and restoresetSelectedTab(newIouType)in theonTabSelectedcallback. This prevents the Onyx roundtrip fromTab.setSelectedTab()from triggering a re-render of the page during the initial mount sequence.What alternative solutions did you explore? (Optional)
IOURequestStepAmount.tsxto exceed the Onyx roundtrip window. This is fragile and timing-dependent — not recommended.useRefinstead of direct derivation forselectedTabto avoid re-renders. This would work but is more complex than restoring the provenuseStatepattern.Next Steps for Contributor+ team: Reply with
@MelvinBot implement thisto create a draft PR,@MelvinBot <your feedback>to refine this analysis, or explain why you are rejecting Melvin's proposal.rlinoz commentedon Mar 12, 2026
I can't repro this and the theoretically offending PR is already in prod...
22 remaining items
melvin-bot commentedon May 4, 2026
This issue has not been updated in over 15 days. @rlinoz, @ChavdaSachin eroding to Monthly issue.
P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do!
rlinoz commentedon May 5, 2026
Still on hold.
moxw commentedon Jun 5, 2026
Proposal
What is the root cause of that problem?
The amount field is focused by a delayed effect in
IOURequestStepAmount:src/pages/iou/request/step/IOURequestStepAmount.tsxschedulestextInput.current?.focus()afterCONST.ANIMATED_TRANSITION + 100.IOURequestStartPagefor FAB > Create Expense.The focus is then lost because
IOURequestStartPagenow derivesselectedTabdirectly from Onyx:OnyxTabNavigatorwrites the selected tab back to the same Onyx key during its initial/tab state event viaTab.setSelectedTab(), then callsonTabSelected(). That callback runsuseResetIOUType, which can callKeyboard.dismiss()and rebuild/update the draft transaction.So the failing chain is:
startMoneyRequest()to the create expense tab route.OnyxTabNavigatorpersists the selected tab during the same mount/tab-selection window.IOURequestStartPagereceives that Onyx update and re-renders layout-affecting props such asScreenWrapper.shouldEnableMaxHeight,DragAndDropProvider.isDisabled, andtransactionRequestType.useResetIOUTypemay also dismiss the keyboard and update the draft transaction.This is timing-sensitive, which explains why it can be intermittent and dependent on the existing persisted selected tab / draft transaction state.
What changes do you think we should make in order to solve the problem?
Restore a local
selectedTabbuffer inIOURequestStartPageinstead of rendering directly from the Onyx value.Specifically:
lastSelectedTab.onTabSelectedcallback, callsetSelectedTab(newIouType)immediately beforeresetIOUTypeIfChanged(newIouType).That keeps the tab UI stable during the initial Onyx roundtrip and prevents the parent create-expense page from re-rendering after the amount input’s delayed focus has already been scheduled.
As hardening,
useResetIOUTypeshould avoid dismissing the keyboard for no-op tab selections. Thetransaction?.iouRequestType === newIOUTypeguard should happen beforeKeyboard.dismiss(), because an initial tab state event that confirms the already-selected tab should not blur the active amount input.Verification plan:
selectedTab_iouRequestType, then use FAB > Create Expense and land on/open the Manual amount tab.IOURequestStartPage/OnyxTabNavigatorverifying that the initial selected-tab Onyx write does not cause a post-focus blur/no-op keyboard dismiss for the amount step.What alternative solutions did you explore? (Optional)
Increasing the amount-step focus timeout would only hide the race and would still be vulnerable to slower Onyx updates.
Forcing another focus from
NumberWithSymbolFormorMoneyRequestAmountInputis also too narrow because the blur is caused by parent tab/Onyx state churn, not by amount formatting itself. The fix should stabilize the tab state boundary and avoid dismissing the keyboard on no-op tab initialization.rlinoz commentedon Jun 8, 2026
@ChavdaSachin how is that issue going?
ChavdaSachin commentedon Jun 11, 2026
This issue was resolved somewhere.
I don't remember where, though.
POC
Screen.Recording.2026-06-11.at.9.40.55.PM.mov
rlinoz commentedon Jun 11, 2026
ah thanks, closing then