Focus after help side panel modal is fully closed#60612
Focus after help side panel modal is fully closed#60612francoisl merged 7 commits intoExpensify:mainfrom
Conversation
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-04-28.at.4.28.37.PM.movAndroid: mWeb ChromeScreen.Recording.2025-04-28.at.4.34.01.PM.moviOS: NativeSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2025-04-28.at.16.17.12.mp4iOS: mWeb SafariSimulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2025-05-09.at.12.06.41.mp4MacOS: Chrome / SafariScreen.Recording.2025-04-28.at.4.29.37.PM.movMacOS: DesktopScreen.Recording.2025-04-28.at.4.59.16.PM.mov |
@bernhardoj, do you have any updates on this? I can view the console logs on mWeb Safari. Please let me know if you need anything from me.
|
|
Let me try again |
|
Ok, it doesn't happen anymore after I merge with main. The input is now refocused on iOS mWeb too. |
|
@bernhardoj This is still reproducible for me: Simulator.Screen.Recording.-.iPhone.15.Pro.Max.-.2025-04-29.at.13.01.08.mp4 |
|
Oh, my bad, I forgot that we should open the help page. I open the clear after instead 😅 |
|
Hmm, I still can't see the console. Even the element inspector doesn't show. Not sure what's wrong with the inspector. asd.mp4 |
|
@bernhardoj I can help you with this. Where do you need to add logs? I'll test and share a video with you. |
|
I initially wanted to add the log to the useAutoFocusInput to see if the refocus logic is actually working, and it looks like it is, but I noticed that on iOS mWeb, the input is immediately blurred afterwards. If I add a timeout (like 1s), then it works fine. The blur is either coming somewhere from our code, or it's from the browser. |
|
@bernhardoj It seems that the issue with iOS Safari originates from here: App/src/pages/settings/Profile/CustomStatus/StatusPage.tsx Lines 200 to 202 in 12bb191 Adding |
|
@rayane-d that is only triggered when the emoji picker hides, right? I think I finally found the root cause. It's all because of our focus trap on the modal. I think the refocus still happens too early before the modal is unmounted, so when we do the refocus, the focus trap will take the focus back. I still can't use the web inspector, so it's really hard to debug. |
|
Finally found the fix. I have some suspicion that the refocus logic doesn't wait until the modal is closed, so I debug it from Android Chrome, and it's true. Our custom BaseModal calls But the help modal component on the web doesn't use our modal component, App/src/components/SidePanel/HelpModal/index.tsx Lines 57 to 77 in 884ba29 so the ready promise doesn't exist and the refocus happens immediately. |
|
|
||
| // Web back button: push history state and close Side Panel on popstate | ||
| useEffect(() => { | ||
| const uniqueModalId = ComposerFocusManager.getId(); |
There was a problem hiding this comment.
Let's call ComposerFocusManager.getId outside of the useEffect
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/francoisl in version: 9.1.45-0 🚀
|
|
🚀 Deployed to staging by https://github.com/francoisl in version: 9.1.45-0 🚀
|

Explanation of Change
Fixed Issues
$ #59397
PROPOSAL: #59397 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
android.mp4
Android: mWeb Chrome
android.mweb.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4