-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 2025-01-24] [$250] Distance- Waypoint is saved when distance editor RHP is refreshed and dismissed without saving #52413
Comments
Triggered auto assignment to @joekaufmanexpensify ( |
Edited by proposal-police: This proposal was edited at 2024-11-21 19:03:45 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.Distance- Waypoint is saved when distance editor RHP is refreshed and dismissed without saving What is the root cause of that problem?We already have a code that is run on unmount to restore transaction here
But it is never called for the case of a reloading the page so when it is opened after refresh we re-load the changed transaction to the backup so if we dismiss it will have the new waypoints
What changes do you think we should make in order to solve the problem?We should update to only load backup transaction if the the transactionBackup is empty
Note that this will fix the bug not only on page reloadrefresh but also for app closing and reopening 👍 Or optionally we need the setTimeout b/c by the time the effect is run useOnyx will not populate transactionBackup but
|
Edited by proposal-police: This proposal was edited at 2024-11-13 06:06:56 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.Waypoint is saved when distance editor RHP is refreshed and dismissed without saving What is the root cause of that problem?When the page is reloaded, we can't execute this code to restore the original transaction from the backup. App/src/pages/iou/request/step/IOURequestStepDistance.tsx Lines 222 to 236 in 3897516
After the reload is complete, create a backup transaction with data that has not been restored to the original transaction. This causes the issue where we still see the waypoint edited but not saved App/src/pages/iou/request/step/IOURequestStepDistance.tsx Lines 214 to 220 in 3897516
What changes do you think we should make in order to solve the problem?To resolve this issue, we need to check if the page is reloaded, then we don't need to create a new backup with the edited data. By the following steps: 1 Create a new Onyx to indicate whether the page is reloaded or not // src/ONYXKEYS.ts#L459
+ EDIT_DISTANCE_PAGE_RELOAD: 'editDistancePageReload_', 2 Listen for the event before the reload // src/pages/iou/request/step/IOURequestStepDistance.tsx#L214
+ useEffect(() => {
+ window.addEventListener('beforeunload', () => {
+ Onyx.set(`${ONYXKEYS.EDIT_DISTANCE_PAGE_RELOAD}${transactionID}`, true);
+ });
+ return () => {
+ window.removeEventListener('beforeunload', () => {
+ Onyx.set(`${ONYXKEYS.EDIT_DISTANCE_PAGE_RELOAD}${transactionID}`, false);
+ });
+ Onyx.set(`${ONYXKEYS.EDIT_DISTANCE_PAGE_RELOAD}${transactionID}`, false);
+ };
+ }, [transactionID]); 3 Add loading to wait value of edit distance reload // src/pages/iou/request/step/IOURequestStepDistance.tsx#L75
+ const [isEditDistancePageRefreshing, isEditDistancePageResult] = useOnyx(`${ONYXKEYS.EDIT_DISTANCE_PAGE_RELOAD}${transactionID}`);
// src/pages/iou/request/step/IOURequestStepDistance.tsx#L530
+ if (isLoadingOnyxValue(isEditDistancePageResult)) {
+ return <FullScreenLoadingIndicator />;
+ } 4 Add condition to check create new back up or not. // src/pages/iou/request/step/IOURequestStepDistance.tsx#L215
useEffect(() => {
if (isCreatingNewRequest) {
return () => {};
}
// On mount, create the backup transaction.
- TransactionEdit.createBackupTransaction(transaction);
+ InteractionManager.runAfterInteractions(() => {
+ requestAnimationFrame(() => {
+ // On mount, create the backup transaction.
+ if (isTransactionPageRefreshing === true || isTransactionPageRefreshing === undefined) {
+ if (transactionWasSaved.current) {
+ TransactionEdit.removeBackupTransaction(transaction?.transactionID ?? '-1');
+ return;
+ }
+ TransactionEdit.restoreOriginalTransactionFromBackup(transaction?.transactionID ?? '-1', IOUUtils.shouldUseTransactionDraft(action));
+ if (!transaction?.reportID) {
+ return;
+ }
+ Report.openReport(transaction?.reportID);
+ return;
+ }
+ TransactionEdit.createBackupTransaction(transaction);
+ });
+ });
return () => {
// If the user cancels out of the modal without without saving changes, then the original transaction
// needs to be restored from the backup so that all changes are removed.
if (transactionWasSaved.current) {
TransactionEdit.removeBackupTransaction(transaction?.transactionID ?? '-1');
return;
}
TransactionEdit.restoreOriginalTransactionFromBackup(transaction?.transactionID ?? '-1', IOUUtils.shouldUseTransactionDraft(action));
// If the user opens IOURequestStepDistance in offline mode and then goes online, re-open the report to fill in missing fields from the transaction backup
if (!transaction?.reportID) {
return;
}
Report.openReport(transaction?.reportID);
};
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []); POCScreen.Recording.2024-11-13.at.12.57.58.mp4Test BranchWhat alternative solutions did you explore? (Optional) |
Reproduced. |
Job added to Upwork: https://www.upwork.com/jobs/~021857103747653162057 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rayane-djouah ( |
@joekaufmanexpensify, @rayane-djouah Whoops! This issue is 2 days overdue. Let's get this updated quick! |
Reviewing |
@FitseTLT, could you please share a code example that demonstrates how to fix the bug by modifying the |
Will provide tomorrow 👍 |
@rayane-djouah What do you think about my proposal above? |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
@rayane-djouah U can check it now. Updated |
@joekaufmanexpensify could you please clarify the expected behavior? When we open a distance request, edit the itinerary on the Distance Editor RHP page, and then refresh the page without saving, should the changes be discarded (similar to dismissing the Distance Editor RHP)? Or should the changes persist as a draft until we either dismiss the page or click "Save"? |
Left thoughts here. I would expect us not to save the behavior if you refresh the page without saving. |
Updated according to the expectation above. |
@joekaufmanexpensify @rayane-djouah 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! |
Moving to weekly given PRs are in review. |
PRs still in review |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.86-3 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 2025-01-24. 🎊 For reference, here are some details about the assignees on this issue:
|
@rayane-djouah @joekaufmanexpensify @rayane-djouah The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button] |
@rayane-djouah could you handle checklist here? TY! |
Asked here |
BugZero Checklist:
Bug classificationSource of bug:
Where bug was reported:
Who reported the bug:
Regression Test Proposal
Do we agree 👍 or 👎 |
Added regression test issue above. All set to issue payment! |
We need to pay:
|
@FitseTLT $250 sent and contract ended! |
@rayane-djouah $250 sent and contract ended! |
Upwork job closed. |
All set, thanks everyone! |
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.60-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: N/A
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Email or phone of affected tester (no customers): [email protected]
Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
The waypoint added in Step 6 will not appear because the new distance is not saved
Actual Result:
The waypoint added in Step 6 appears even when the new distance is not saved
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6662755_1731429445776.20241113_003143.1.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @joekaufmanexpensifyThe text was updated successfully, but these errors were encountered: