fix: mobile doesn't need manual focus anymore for autoFocus #54755
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
There is a bug in react native where calling
textInputRef.focus()
doesn't focus the text input. That is the reason for the bug which this PR wants to fix. This kind of bug doesn't happen when we use theautoFocus
native prop on theTextInput
.I figured, instead of going down the rabbit hole and analyzing why
.focus()
became broken in certain conditions, we should start to rely on theautoFocus
prop again.In the past we use to manually call
textInputRef.focus()
to circumvent a bunch of bugs. However, now that we are:those previous problems don't really exist anymore, and it seems safe to remove our manually calling code. (I think it's also cleaner to remove our "custom" code and instead rely on the build in APIs such as the
autoFocus
prop).Note
For now I have kept the
shouldDelayFocus
prop. I think we should be able to remove this prop as well as it was only helping us to circumvent certain bugs, but:autoFocus
prop and we need to investigate why that happensOpened a follow up ticket here:
shouldDelayFocus
prop #54759Fixed Issues
$ #54658
PROPOSAL: #54658
Tests
Additionally make sure all other text inputs when navigating through the app are still being auto focused.
Offline tests
n/a
QA Steps
Same as testing steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Screen_Recording_20250102_141359_New.Expensify.Dev.mp4
Android: mWeb Chrome
Screen_Recording_20250102_144524_Samsung.Internet.mp4
iOS: Native
ios_after.MP4
iOS: mWeb Safari
ios_mWeb.MP4
MacOS: Chrome / Safari
CleanShot.2025-01-02.at.14.39.03.mp4
MacOS: Desktop
CleanShot.2025-01-02.at.14.48.53.mp4