Prevent keyboard from appearing over splash screen on iOS app reopen#85396
Draft
Prevent keyboard from appearing over splash screen on iOS app reopen#85396
Conversation
Add iOS-specific isWindowReadyToFocus implementation that blocks focus operations during background-to-foreground transitions, add global Keyboard.dismiss() on iOS foreground transition, and gate Magic Code input focus with isWindowReadyToFocus. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
7 tasks
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
When the iOS app is reopened after being backgrounded on a screen with a focused input (DM composer or Magic Code screen), the keyboard appears on top of the system splash/transition screen before the app finishes loading. This creates a jarring visual experience, especially on slower devices.
Three changes address this:
iOS-specific
isWindowReadyToFocus(src/libs/isWindowReadyToFocus/index.ios.ts): Mirrors the existing Android implementation. Listens forAppStatechanges and creates a blocking promise when the app goes tobackground/inactive, which only resolves when the app transitions back toactive. All code paths that already callisWindowReadyToFocus()(includingfocusComposerWithDelayanduseAutoFocusInput) automatically gain iOS protection.Global
Keyboard.dismiss()on foreground transition (src/Expensify.tsx): An iOS-onlyAppStatelistener dismisses the keyboard when the app transitions frominactive/backgroundtoactive. This handles the native UIKit first responder restoration that happens independently of React-level focus calls.Gate Magic Code focus (
BaseValidateCodeForm.tsx): Wraps thefocusLastSelected()call insideuseFocusEffectwithisWindowReadyToFocus(), preventing premature keyboard display during the background-to-foreground transition on the Magic Code screen.Fixed Issues
$ #84324
PROPOSAL: #84324 (comment)
Tests
On iOS, open a DM conversation so the composer is focused and keyboard is visible
Background the app (swipe up to go home)
Reopen the app
Verify the keyboard does NOT appear over the splash/transition screen
Verify the keyboard appears only after the app finishes loading the screen
On iOS, navigate to a Magic Code screen (e.g., Biometric test on Troubleshoot page)
Background the app
Reopen the app
Verify the keyboard does NOT flash over the splash screen
On iOS, reopen the app from a screen without a focused input
Verify no keyboard appears at all
On Android, open a DM conversation and background/reopen the app
Verify the composer still refocuses correctly (no regression)
On Web, verify composer focus behavior is unchanged
Offline tests
N/A — This change only affects keyboard focus timing during background-to-foreground transitions and does not involve network operations.
QA Steps
On an iOS device, open the app and navigate to a DM screen so the keyboard is showing
Background the app (press Home or swipe up)
Reopen the app
Verify the splash/transition screen appears without the keyboard overlapping it
Verify the keyboard appears only after the app has fully loaded
Navigate to a Magic Code screen, background the app, then reopen
Verify the keyboard does not flash over the splash screen
On Android, repeat steps 1-5 and verify no regression in composer focus behavior
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))npm run compress-svg)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
N/A — No visual changes on Android, existing behavior preserved
Android: mWeb Chrome
N/A — Changes are iOS-native only
iOS: Native
iOS-specific fix — keyboard no longer appears over splash/transition screen on app reopen
iOS: mWeb Safari
N/A — Changes are iOS-native only
MacOS: Chrome / Safari
N/A — Changes are iOS-native only