Make NetSuiteInvoiceItemPreferenceSelectPage use new SelectionList#73935
Conversation
…erd03/migrate-NetSuiteInvoiceItemPreferenceSelectPage
…erd03/migrate-NetSuiteInvoiceItemPreferenceSelectPage
| const selectedIndex = options.findIndex((option) => option.isSelected); | ||
| if (selectedIndex !== -1 && selectionListRef.current) { | ||
| selectionListRef.current?.updateFocusedIndex(selectedIndex); | ||
| } |
There was a problem hiding this comment.
❌ PERF-6 (docs)
The options array is recreated on every render (line 43), causing this useEffect to run unnecessarily. Passing the entire options array causes the hook to re-execute whenever any property changes in the dependency chain.
Suggested fix: Use specific primitive dependencies instead:
useEffect(() => {
const selectedIndex = options.findIndex((option) => option.isSelected);
if (selectedIndex !== -1 && selectionListRef.current) {
selectionListRef.current?.updateFocusedIndex(selectedIndex);
}
}, [selectedValue]);Since selectedValue already determines which option is selected, and options array structure doesn't change (only the isSelected property changes based on selectedValue), using selectedValue as the sole dependency is more granular and prevents unnecessary re-executions.
There was a problem hiding this comment.
The options array has only two elements, so for the sake of clear code I just pust this find(... inside useEffect and then I put it also to the dependencies.
I don't think there's need to change it, if someone thinks different I'm here to discuss 😊
There was a problem hiding this comment.
I think that without react compiler this might result in an infinite loop. The safest approach would be to add useMemo to options
Codecov Report❌ Patch coverage is
... and 27 files with indirect coverage changes 🚀 New features to boost your workflow:
|
src/pages/workspace/accounting/netsuite/export/NetSuiteInvoiceItemPreferenceSelectPage.tsx
Show resolved
Hide resolved
|
@rushatgabhane 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] |
src/pages/workspace/accounting/netsuite/export/NetSuiteInvoiceItemPreferenceSelectPage.tsx
Show resolved
Hide resolved
|
Left a comment here |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppScreen.Recording.2025-11-04.at.23.12.51.movAndroid: mWeb ChromeScreen.Recording.2025-11-04.at.23.10.34.moviOS: HybridAppScreen.Recording.2025-11-04.at.23.13.48.moviOS: mWeb SafariScreen.Recording.2025-11-04.at.23.11.00.movMacOS: Chrome / SafariScreen.Recording.2025-11-04.at.23.01.36.movMacOS: DesktopScreen.Recording.2025-11-04.at.23.14.37.mov |
|
🚀 Deployed to staging by https://github.com/grgia in version: 9.2.46-0 🚀
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.2.46-3 🚀
|
Explanation of Change
Fixed Issues
$ #72969
PROPOSAL:
Tests
WorkspacestabAccountingtabNetSuiteaccounting system to the workspaceExport->Invoice ItemNetSuiteInvoiceItemPreferenceSelectPageis working correctly7.1. It's important to check this page also with
Simulate failing network requestsenabled inTroubleshootOffline tests
QA Steps
as above
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.mp4
Android: mWeb Chrome
android-web.mp4
iOS: Native
ios.mov
iOS: mWeb Safari
ios-web.mov
MacOS: Chrome / Safari
Web without errors
web.mov
Web with error
web-with-errors.mov
MacOS: Desktop