-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[HOLD for payment 2024-11-01] [$250] Search - Selection persists after the expense is deleted and no expense is selected #50021
Comments
We think that this bug might be related to #wave-control |
Triggered auto assignment to @OfstadC ( |
@OfstadC FYI I haven't added the External label as I wasn't 100% sure about this issue. Please take a look and add the label if you agree it's a bug and can be handled by external contributors |
Edited by proposal-police: This proposal was edited at 2024-10-11 22:25:51 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.The selection header is not updated when the search data is changed. What is the root cause of that problem?We do not update the selected header text when the search data changes. What changes do you think we should make in order to solve the problem?
const data = searchResults ? SearchUtils.getSections(type, status, searchResults?.data, searchResults?.search) : [];
useEffect(() => {
// Check if there are any selected transactions before proceeding
if (!Object.keys(selectedTransactions).length) {
return; // Exit if no selected transactions
}
if (!data || data.length ===0) {
// Clear selected transactions if there’s no data
clearSelectedTransactions();
} else {
// Create a new object to store the updated transactions
const updatedTransactions: SelectedTransactions = {};
// Loop over selected transactions and validate if they exist in the current data
Object.keys(selectedTransactions).forEach((key) => {
const transactionExists = data.some((item) => {
if (SearchUtils.isTransactionListItemType(item)) {
return item.keyForList === key;
} else if (!SearchUtils.isReportActionListItemType(item)) {
return item?.transactions?.some((transaction) => transaction.keyForList === key);
}
return false;
});
// If the transaction exists, keep it in updatedTransactions
if (transactionExists) {
updatedTransactions[key] = selectedTransactions[key];
}
});
// Update the context with the new selected transactions and reports
setSelectedTransactions(updatedTransactions, data);
}
}, [data]);
What alternative solutions did you explore? (Optional) |
ProposalPlease re-state the problem that we are trying to solve in this issue.Search - Selection persists after the expense is deleted and no expense is selected What is the root cause of that problem?In SearchPage we don't have a effect to clear the selected transactions and to turn off the mobile selection mode when the component unmounts. What changes do you think we should make in order to solve the problem?
useEffect(
() => () => {
clearSelectedTransactions();
turnOffMobileSelectionMode();
},
[isFocused, clearSelectedTransactions],
); Optional: We can call What alternative solutions did you explore? (Optional)
What alternative solutions did you explore? (Optional 2)
useEffect(
() => () => {
if (isSearchTopmostCentralPane()) {
return;
}
clearSelectedTransactions();
turnOffMobileSelectionMode();
},
[isFocused, clearSelectedTransactions],
); ResultMonosnap.screencast.2024-10-13.19-30-26.mp4 |
ProposalPlease re-state the problem that we are trying to solve in this issue.Selection persists after the expense is deleted and no expense is selected What is the root cause of that problem?We do not update What changes do you think we should make in order to solve the problem?We should update selectedTransactionsData when deleting an expense to keep it up to date, something like this: // add function to update `selectedTransactionsData`
// .src/components/Search/SearchContext.tsx#L56
+ const updateSelectedTransactions = useCallback((selectedTransactions: SelectedTransactions) => {
+ setSearchContextData((prevState) => ({
+ ...prevState,
+ selectedTransactions,
+ }));
+ }, []);
// .src/components/Search/SearchContext.tsx#L56
const searchContext = useMemo<SearchContext>(
() => ({
...
+ updateSelectedTransactions // Update function delete expense
// .src/pages/ReportDetailsPage.tsx#L718
+ const {selectedTransactions, updateSelectedTransactions, clearSelectedTransactions} = useSearchContext();
// .src/pages/ReportDetailsPage.tsx#L734
const deleteTransaction = useCallback(() => {
...
+ const updateSelectedTransactionsData = Object.keys(selectedTransactions)
+ .filter((key) => String(key) !== String(iouTransactionID)) // Ensure both are strings for comparison
+ .reduce((obj, key) => {
+ obj[key] = selectedTransactions[key];
+ return obj;
+ }, {});
+ if (!Object.keys(updateSelectedTransactionsData).length) {
+ clearSelectedTransactions();
+ } else {
+ updateSelectedTransactions(updateSelectedTransactionsData);
+ }
navigateBackToAfterDelete.current = IOU.deleteMoneyRequest(iouTransactionID, requestParentReportAction,
isSingleTransactionView);
We will create this logic to handle updating Note: We can optimize updateSelectedTransactions by passing // ReportDetailsPage.tsx or MoneyReportHeader.tsx
updateSelectedTransactions(iouTransactionID);
// SearchContext.tsx
const updateSelectedTransactions = useCallback((iouTransactionID: string) => {
const updateSelectedTransactionsData = Object.keys(searchContextData.selectedTransactions)
.filter((key) => String(key) !== String(iouTransactionID)) // Ensure both are strings for comparison
.reduce((obj, key) => {
obj[key] = searchContext.selectedTransactions[key];
return obj;
}, {});
setSearchContextData((prevState) => ({
...prevState,
selectedTransactions: updateSelectedTransactionsData,
}));
}, []);
POC
Screen.Recording.2024-10-02.at.17.40.26.mp4 |
Job added to Upwork: https://www.upwork.com/jobs/~021842230940180729212 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @Ollyws ( |
Will get to this one today/tomorrow |
@abzokhattabs proposal LGTM, but I think the alternative proposal of using |
Triggered auto assignment to @MarioExpensify, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@Ollyws, I believe we should just clear the selection as soon as we leave the search page. This is the behaviour accross the app. I'm not sure why do we need to persist the selection after leaving the page, am I missing something? |
@OfstadC Can you give us your input regarding @Krishna2323's comment? I'm not sure what would be our preferred behavior regarding this issue. |
Here is one possible regression that would occur if we clear the selected transactions based on the i don't think we want this behavior Screen.Recording.2024-10-08.at.11.22.14.PM.mov |
That's not a bug, it's the behaviour we decided to use across the app. selection_bug.mp4 |
This was not decided to use "across the app" it was decided for the "workspace settings" taps only .. the search page is different. a scenario that doesn't exist in the workspace settings: Screen.Recording.2024-10-09.at.12.42.02.movI think making it dependent on the data would provide a better user experience, as the user wouldn’t have to reselect search items if the focus changes. but yeah lets see what others think |
📣 @Krishna2323 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
Let's move forward with @Krishna2323 proposal with the option to keep the selection while the user does not leave the page. Thank you @Ollyws. |
@Ollyws @OfstadC @Krishna2323 @MarioExpensify this issue was created 2 weeks ago. Are we close to approving a proposal? If not, what's blocking us from getting this issue assigned? Don't hesitate to create a thread in #expensify-open-source to align faster in real time. Thanks! |
Great, please assign them @MarioExpensify |
@Ollyws, I'm already assigned :), will raise the PR today. |
@Ollyws, PR ready for review ^ |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.53-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2024-11-01. 🎊 For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
@Ollyws please complete the BZ checklist by Thursday EOD so I can issue payment on Friday 😃 Thanks! |
BugZero Checklist:
Seems like this has been the behaviour since the creation of the component.
N/A
N/A
Yes
Regression Test Proposal
Do we agree 👍 or 👎 |
Payment Summary
Job posting Closed - QA Issue created |
@OfstadC @MarioExpensify Be sure to fill out the Contact List! |
Requested in ND. |
$250 approved for @Ollyws |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.42-0
Reproducible in staging?: Y
Reproducible in production?: Y
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause Internal Team
Action Performed:
Expected Result:
The selection should reset because the expense is deleted.
Actual Result:
The dropdown button remains as "1 selected" when the expense is deleted and no expense is selected.
Workaround:
Unknown
Platforms:
Screenshots/Videos
Bug6621388_1727806755633.bandicam_2024-10-02_02-13-52-036.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @OfstadCThe text was updated successfully, but these errors were encountered: