[CP Staging] Guard against false-positive focus match in FAB menu items#85715
[CP Staging] Guard against false-positive focus match in FAB menu items#85715cristipaval merged 1 commit intomainfrom
Conversation
When focusedIndex is -1 (initial/reset state) and an unregistered item also has itemIndex -1, the equality check incorrectly marks the item as focused. Add an explicit guard so isFocused is only true when focusedIndex is a valid non-negative index. Co-authored-by: Aimane Chnaif <aimane-chnaif@users.noreply.github.com>
|
@MelvinBot review |
Code ReviewChange: One-line guard in AnalysisThe fix is correct and minimal. Here's why the bug occurs:
The guard VerdictLGTM — The fix is clean, targeted, and addresses the root cause without side effects. No concerns. Note on CI: The failing |
|
The failing check is unrelated to this PR. Analysis: The only failure is in Evidence:
You can re-run the failing job to unblock the PR. |
|
@MelvinBot mark as ready for review |
|
PR marked as ready for review. |
|
@aimane-chnaif Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppfix.movAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
Codecov Report✅ Changes either increased or maintained existing code coverage, great job!
|
[CP Staging] Guard against false-positive focus match in FAB menu items (cherry picked from commit 5308dad) (cherry-picked to staging by mountiny)
|
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.3.40-6 🚀
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚧 @cristipaval has triggered a test Expensify/App build. You can view the workflow run here. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.3.40-10 🚀
|
|
🚀 Cherry-picked to staging by https://github.com/mountiny in version: 9.3.41-0 🚀
Bundle Size Analysis (Sentry): |
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.3.41-4 🚀
|
Explanation of Change
When the FAB menu's
focusedIndexis at its initial/reset value of-1and an item hasn't been registered yet (registeredItems.indexOf()also returns-1), the equality checkfocusedIndex === itemIndexincorrectly evaluates totrue(-1 === -1). This causes the item to render in a focused state with green icon color on Android when reopening the FAB.This adds an explicit guard (
focusedIndex !== -1) so thatisFocusedis onlytruewhenfocusedIndexis a valid non-negative index, preventing the false positive match.Fixed Issues
$ #85685
PROPOSAL: #85685 (comment)
Tests
Offline tests
N/A — this change is purely visual/UI state and does not involve network calls.
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))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