Fix: Expense - Expense RHP composer does not not auto focus when opened from report RHP#81645
Fix: Expense - Expense RHP composer does not not auto focus when opened from report RHP#81645annaweber830 wants to merge 4 commits intoExpensify:mainfrom
Conversation
| const delay = shouldDelayAutoFocus ? CONST.ANIMATED_TRANSITION : CONST.COMPOSER_FOCUS_DELAY; | ||
| focusComposerWithDelay(textInputRef.current, delay)(shouldDelay); | ||
| }, | ||
| [shouldDelayAutoFocus], |
There was a problem hiding this comment.
❌ PERF-12 (docs)
The focus callback now has shouldDelayAutoFocus in its dependency array, but this variable changes based on navigation state (superWideRHPRouteKeys.length). This means the focus callback will be recreated every time the RHP stack changes, which could cause issues with any code that depends on referential stability of the focus function.
Suggested fix:
Consider using a ref to track shouldDelayAutoFocus to maintain referential stability of the focus callback:
const shouldDelayAutoFocusRef = useRef(shouldDelayAutoFocus);
shouldDelayAutoFocusRef.current = shouldDelayAutoFocus;
const focus = useCallback((shouldDelay = false) => {
const delay = shouldDelayAutoFocusRef.current ? CONST.ANIMATED_TRANSITION : CONST.COMPOSER_FOCUS_DELAY;
focusComposerWithDelay(textInputRef.current, delay)(shouldDelay);
}, []);This ensures the callback identity remains stable while still accessing the current value of shouldDelayAutoFocus.
Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.
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.
|
|
@annaweber830 correct me if I'm wrong, but should autofocus work in native mode as well? Screen.Recording.2026-02-06.at.10.04.41.movThank you. |
|
Hi @brunovjk Should autofocus work in native mode? |
|
I believe so, but it's good to confirm. @chuckdries what do you think? Should autofocus work in native? Thank you. |
Explanation of Change
Fix: Expense - Expense RHP composer does not not auto focus when opened from report RHP
Fixed Issues
$ #79860
PROPOSAL: #79860 (comment)
Tests
Offline tests
Same as test
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand 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
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
Screen.Recording.2026-02-05.at.9.42.52.PM.mp4