fix: cards are not sorted after page refresh#65806
fix: cards are not sorted after page refresh#65806AndrewGable merged 4 commits intoExpensify:mainfrom
Conversation
|
@QichenZhu 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: HybridAppandroid-native.mp4Android: mWeb Chromeandroid-web.mp4iOS: HybridAppios-native.mp4iOS: mWeb Safariios-web.mp4MacOS: Chrome / Safarimac-web.movMacOS: Desktopmac-desktop.mov |
|
@linhvovan29546, I noticed the card order shifts briefly when the page loads. Maybe it's because I'm using fake data. Can you check if it happens on your side? Screen.Recording.2025-07-11.at.17.03.50.mov |
|
NAB: The card list is empty when you access it through a link while logged out. This already exists on staging. staging-bug.mov |
I'm don't see briefly in my side(i'm also using fake data, which initially displays an empty page), i think that may because the sort inside |
|
@linhvovan29546, thanks for the confirming! I don't have one yet. I've asked the internal team for help. |
QichenZhu
left a comment
There was a problem hiding this comment.
Confirmed order shifting happens with real data too. Otherwise looks good.
If @AndrewGable or QA think it's an issue, I can take it and raise a follow-up PR since @linhvovan29546 can't reproduce it.
|
@QichenZhu Perhaps my first alternative solution will resolve this issue? |
|
@linhvovan29546, there's a App/src/hooks/useSearchResults.ts Lines 16 to 17 in 9332bd1 |
|
@AndrewGable, I approved the PR but have a concern in this comment. Could you take a look when you have a moment? Thanks! |
|
Seems like a bug for sure. I am not sure how testing data would cause this? |
I'm not sure if we intended that case. I think we use |
Thanks for confirming. We'll work on a fix.
It turns out this isn't caused by the testing data. |
Thanks @linhvovan29546, that makes sense. But only sorting inside |
|
I think sorting inside useState() should be sufficient. There's no need to filter here since initially, we don't have a search value. Does this approach resolve your issue? |
|
Yes, it does. Let's do it. |
This hook is used in many places, so do you think we should add the sort to the initial state based on the flag? I think that would be safer. Then I’ll provide an update tomorrow |
Sounds good! |
|
@QichenZhu This is ready for review! |
QichenZhu
left a comment
There was a problem hiding this comment.
Re-reviewed and retested. Both the original issue and this issue are fixed.
|
@AndrewGable, could you take another look when you have a chance? |
|
✋ 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 staging by https://github.com/AndrewGable in version: 9.1.85-2 🚀
|
|
🚀 Deployed to production by https://github.com/cristipaval in version: 9.1.85-5 🚀
|
| ) { | ||
| const [inputValue, setInputValue] = useState(''); | ||
| const [result, setResult] = useState(data); | ||
| const [result, setResult] = useState(() => (shouldSortInitialData ? sortData(data) : data)); |
There was a problem hiding this comment.
we should have fixed at other places as well on similar issue. Ref - #70659 (comment)
Explanation of Change
This PR applies a shallow copy to the
datato fix the issue where the sorted data does not re-render when usingsetState.For more detail please check the proposal below
Fixed Issues
$ #62202
PROPOSAL: #62202 (comment)
Tests
Note: If you don’t have access to the account above, you will need to mock the card local.
Offline tests
Same as tests above
QA Steps
Same as tests 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))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
Screen.Recording.2025-07-10.at.10.47.49.mov
iOS: Native
iOS: mWeb Safari
Screen.Recording.2025-07-10.at.10.42.52.mov
MacOS: Chrome / Safari
Screen.Recording.2025-07-10.at.10.30.23.mov
MacOS: Desktop
Screen.Recording.2025-07-10.at.10.39.01.mov