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 2025-11-17] [$250] Compose box loses focus when switching tabs, breaking keyboard shortcuts on return #72458
Version Number: 9.2.29-5 Reproducible in staging?: Y Reproducible in production?: Y If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by:@cead22 Slack conversation (hyperlinked to channel name): #Quality
Action Performed:
Open a chat in NewDot
Type some text in the compose box
Switch to another browser tab
Switch back to the NewDot tab
Try pressing:
CMD + A (select all text)
CMD + LEFT or OPTION + LEFT (move cursor)
Expected Result:
Focus should return seamlessly to the compose box after switching tabs, Keyboard shortcuts should work immediately without needing to click in the box.
Actual Result:
Typing works automatically when returning, but the compose box isn’t truly focused, Keyboard shortcuts like CMD + A and cursor movement commands do not respond until the user manually clicks inside the compose box.
Workaround:
Unknown
Platforms:
Select the officially supported platforms where the issue was reproduced:
Android: App
Android: mWeb Chrome
iOS: App
iOS: mWeb Safari
iOS: mWeb Chrome
Windows: Chrome
MacOS: Chrome / Safari
MacOS: Desktop
Platforms Tested:
On which of our officially supported platforms was this issue tested:
Android: App
Android: mWeb Chrome
iOS: App
iOS: mWeb Safari
iOS: mWeb Chrome
Windows: Chrome
MacOS: Chrome / Safari
MacOS: Desktop
Screenshots/Videos
Add any screenshot/video evidenceRecording.1754.mp4
Please re-state the problem that we are trying to solve in this issue.
When a user switches away from the NewDot browser tab and then comes back, typing into the compose box works, but the browser focus never returns to the input. Because the textarea is not really focused, shortcuts such as ⌘A, ⌘←, or ⌥← fail until the user clicks inside the composer.
What is the root cause of that problem?
The composer only requests focus during explicit focus events or after certain modal transitions. We do not remember that the composer was focused before the window lost focus, and we do not respond to the browser’s window.focus event to restore it. The old handler simply invoked onFocus when React told us the input gained focus, and there was no path to re-focus the element when the window became active again
// The last composer that had focus should re-gain focus
setUpComposeFocusManager(true);
onFocus();
}}
onBlur={onBlur}
What changes do you think we should make in order to solve the problem?
Track whether the composer owned focus, subscribe to the app-focus hook, and restore focus when the tab becomes active so that keyboard shortcuts work immediately.
Please re-state the problem that we are trying to solve in this issue.
Composer loses focus after switching tab.
What is the root cause of that problem?
This is a problem with the live markdown component. This happens after this PR. In that PR, we want to save the focused text input as outlined in the proposal here, so that Keyboard.dismiss will work on live markdown. But since we can't directly access the text input state, we do it through RNTextInput.State.focusTextInput on focus and RNTextInput.State.blurTextInput on blur.
When we switch tabs, the input onBlur is triggered, so the input is blurred. In normal cases, the input doesn't lose focus even though onBlur is called when switching tabs.
What changes do you think we should make in order to solve the problem?
We can update the onBlur code so that it only blurs when the input loses its focus.
if (event.target !== document.activeElement) {
RNTextInput.State.blurTextInput?.(e.target);
}
Please re-state the problem that we are trying to solve in this issue.
Typing works automatically when returning, but the compose box isn’t truly focused, Keyboard shortcuts like CMD + A and cursor movement commands do not respond until the user manually clicks inside the compose box.
What is the root cause of that problem?
When switching to another tab, the current composer (which is a div) will automatically lose focus, and it will not automatically regain focus when the tab is switched back.
What changes do you think we should make in order to solve the problem?
Use the visibilitychange event to listen for tab visibility changes and store the value in a visibilityState.
Treat this visibilityState similarly to isModalVisible inside the useEffect to restore focus when the tab becomes visible again.
changed the title [-]Compose box loses focus when switching tabs, breaking keyboard shortcuts on return[/-][+][$250] Compose box loses focus when switching tabs, breaking keyboard shortcuts on return[/+]on Oct 13, 2025
changed the title [-][$250] Compose box loses focus when switching tabs, breaking keyboard shortcuts on return[/-][+][Due for payment 2025-11-17] [$250] Compose box loses focus when switching tabs, breaking keyboard shortcuts on return[/+]on Nov 10, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.47-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
@ahmedGaber93 / @bernhardoj The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
[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: N/A.
[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.
Activity
melvin-bot commentedon Oct 13, 2025
Triggered auto assignment to @abekkala (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.ShridharGoel commentedon Oct 13, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
When a user switches away from the NewDot browser tab and then comes back, typing into the compose box works, but the browser focus never returns to the input. Because the textarea is not really focused, shortcuts such as
⌘A,⌘←, or⌥←fail until the user clicks inside the composer.What is the root cause of that problem?
The composer only requests focus during explicit focus events or after certain modal transitions. We do not remember that the composer was focused before the window lost focus, and we do not respond to the browser’s
window.focusevent to restore it. The old handler simply invokedonFocuswhen React told us the input gained focus, and there was no path to re-focus the element when the window became active againApp/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx
Lines 806 to 811 in 7a288bc
What changes do you think we should make in order to solve the problem?
Track whether the composer owned focus, subscribe to the app-focus hook, and restore focus when the tab becomes active so that keyboard shortcuts work immediately.
This keeps typing seamless while also restoring the real DOM focus as soon as the window regains focus.
bernhardoj commentedon Oct 13, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Composer loses focus after switching tab.
What is the root cause of that problem?
This is a problem with the live markdown component. This happens after this PR. In that PR, we want to save the focused text input as outlined in the proposal here, so that
Keyboard.dismisswill work on live markdown. But since we can't directly access the text input state, we do it throughRNTextInput.State.focusTextInputon focus andRNTextInput.State.blurTextInputon blur.When we switch tabs, the input
onBluris triggered, so the input is blurred. In normal cases, the input doesn't lose focus even thoughonBluris called when switching tabs.What changes do you think we should make in order to solve the problem?
We can update the onBlur code so that it only blurs when the input loses its focus.
dmkt9 commentedon Oct 13, 2025
Proposal
Please re-state the problem that we are trying to solve in this issue.
Typing works automatically when returning, but the compose box isn’t truly focused, Keyboard shortcuts like CMD + A and cursor movement commands do not respond until the user manually clicks inside the compose box.
What is the root cause of that problem?
When switching to another tab, the current composer (which is a
div) will automatically lose focus, and it will not automatically regain focus when the tab is switched back.What changes do you think we should make in order to solve the problem?
visibilitychangeevent to listen for tab visibility changes and store the value in avisibilityState.visibilityStatesimilarly toisModalVisibleinside theuseEffectto restore focus when the tab becomes visible again.App/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/ComposerWithSuggestions.tsx
Lines 657 to 687 in 89c45c9
melvin-bot commentedon Oct 13, 2025
Job added to Upwork: https://www.upwork.com/jobs/~021977812992564239872
[-]Compose box loses focus when switching tabs, breaking keyboard shortcuts on return[/-][+][$250] Compose box loses focus when switching tabs, breaking keyboard shortcuts on return[/+]melvin-bot commentedon Oct 13, 2025
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ahmedGaber93 (
External)30 remaining items
[-][$250] Compose box loses focus when switching tabs, breaking keyboard shortcuts on return[/-][+][Due for payment 2025-11-17] [$250] Compose box loses focus when switching tabs, breaking keyboard shortcuts on return[/+]melvin-bot commentedon Nov 10, 2025
Reviewinglabel has been removed, please complete the "BugZero Checklist".melvin-bot commentedon Nov 10, 2025
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.2.47-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:
If no regressions arise, payment will be issued on 2025-11-17. 🎊
For reference, here are some details about the assignees on this issue:
melvin-bot commentedon Nov 10, 2025
@ahmedGaber93 / @bernhardoj The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
abekkala commentedon Nov 17, 2025
PAYMENT SUMMARY FOR NOV 17
please compelted checklist
ahmedGaber93 commentedon Nov 17, 2025
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: https://github.com/Expensify/react-native-live-markdown/pull/680/files#r2535491853
[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: N/A.
[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/569622
Regression Test Proposal
Test:
WEB only
Do we agree 👍 or 👎
ahmedGaber93 commentedon Nov 17, 2025
@abekkala checklist have been completed.
bernhardoj commentedon Nov 18, 2025
Requested in ND.
trjExpensify commentedon Nov 18, 2025
approved $250 for @ahmedGaber93.
abekkala commentedon Nov 18, 2025
Posting payment summary once more for better visibility:
PAYMENT SUMMARY FOR NOV 17
Thanks! 🎉
garrettmknight commentedon Nov 21, 2025
$250 approved for @bernhardoj