-
Notifications
You must be signed in to change notification settings - Fork 4k
fix: keyboard is not displayed on iOS for autofocused inputs #58760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
carlosmiceli
merged 2 commits into
Expensify:main
from
callstack-internal:fix/keyboard-not-shown-on-ios
Mar 26, 2025
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@martasudol Could you help to detail the RCA and how this change will fix the problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main issue was likely that ref could be a function when using the
useAutoFocusInputhook, which might have caused unexpected behavior in the keyboard visibility check.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But why useAutoFocusInput doesn't work on this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For clear, in useAutoFocusInput we already implemented a logic to auto focus the input
App/src/hooks/useAutoFocusInput.ts
Line 32 in 8c827d7
And I think we need to point out why it doesn't work on the physical devices
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that autofocus is triggered differently on iOS real devices compared to Android or simulators/emulators - timing and visibility behavior can vary quite a bit depending on the platform.
Anyway, I’ve just tested the latest version of the app on a real iOS device, and it looks like the issue is no longer reproducible - everything works as expected now.
Could you please re-test on your side and confirm whether the bug is still happening for you? 🙏 Looks like someone fixed this in the meantime :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still can reproduce on Chrome on Iphone (with latest main)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You’re right - I was able to reproduce the issue in the browser on iOS as well.
My fix specifically addresses this problem, which only occurs in iOS browsers. The root cause is that React Native for Web doesn’t fully support autofocus for web iOS; a focus trigger is required for autofocus to work properly.
In our case, we use the useAutoFocusInput hook and then pass down the default props, which slightly changes how autofocus is triggered for iOS browsers. This difference in behavior is likely what caused the issue.