-
Notifications
You must be signed in to change notification settings - Fork 3k
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-17] [$250] Add confirmation dialog on unsaved changes #53679
Comments
Edited by proposal-police: This proposal was edited at 2024-12-06 05:23:17 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.Add confirmation dialog on unsaved changes What is the root cause of that problem?New feature What changes do you think we should make in order to solve the problem?
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?NA What alternative solutions did you explore? (Optional)Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job. |
Triggered auto assignment to @abekkala ( |
|
@dubielzyk-expensify make sure you add |
Triggered auto assignment to Design team member for new feature review - @dubielzyk-expensify ( |
Job added to Upwork: https://www.upwork.com/jobs/~021864985847950506437 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @ahmedGaber93 ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Add confirmation dialog on unsaved changes What is the root cause of that problem?New Feature What changes do you think we should make in order to solve the problem?If we start from
to use a modified function as:
we should create translation for the above used texts. Screen.20Recording.202024-12-06.20at.205.mp4 |
Edited by proposal-police: This proposal was edited at 2024-12-10 07:13:19 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.We want to show a discard changes confirmation when closing the page if there is an unsaved changes. What is the root cause of that problem?New feature. What changes do you think we should make in order to solve the problem?Since we want to apply this to many pages, we can create a new component called
Then, to use this in the description page for example, we need to update the input first to be a controlled input. App/src/pages/iou/request/step/IOURequestStepDescription.tsx Lines 153 to 158 in 7d42188
Then, add a
And set it to true here. App/src/pages/iou/request/step/IOURequestStepDescription.tsx Lines 101 to 102 in 8981081
And use the new component like this:
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?N/A |
📣 @bjmmtin! 📣
|
react-hook-form simplifies form management by providing easy-to-use hooks for registering inputs, handling submissions, and tracking form state. import React, { useState } from 'react';
import { useForm } from 'react-hook-form';
import { useBlocker } from 'react-router-dom';
const MyForm = () => {
const { register, handleSubmit, formState: { isDirty } } = useForm({
defaultValues: { name: "", email: "" }
});
const [alertModal, setAlertModal] = useState({ show: false, title: "", content: "" });
const [proceed, setProceed] = useState(false);
const [navigateTo, setNavigateTo] = useState(null);
const onSubmit = (data) => {
console.log(data);
// Reset the form or perform any other action after submission
};
const handleNavigation = ({ nextLocation }) => {
if (isDirty) {
setProceed(true);
setNavigateTo(nextLocation.pathname);
setAlertModal({
show: true,
title: "You have unsaved changes.",
content: "All unsaved changes will be lost.",
});
return false; // Prevent navigation
}
return true; // Allow navigation
};
useBlocker(handleNavigation);
const handleAlertConfirm = () => {
setProceed(false);
setAlertModal({ show: false, title: "", content: "" });
// Navigate to the next location if proceed is true
if (navigateTo) {
// Use your navigation logic here, e.g., using useNavigate from react-router-dom
// navigate(navigateTo);
}
};
return (
<div>
{alertModal.show && (
<div className="alert-modal">
<h2>{alertModal.title}</h2>
<p>{alertModal.content}</p>
<button onClick={handleAlertConfirm}>Proceed</button>
<button onClick={() => setAlertModal({ show: false })}>Cancel</button>
</div>
)}
<form onSubmit={handleSubmit(onSubmit)}>
<input {...register('name')} placeholder="Name" />
<input {...register('email')} placeholder="Email" />
<button type="submit">Submit</button>
</form>
</div>
);
};
export default MyForm; |
Reviewing today |
ProposalPlease re-state the problem that we are trying to solve in this issue.Add confirmation dialog on unsaved changes What is the root cause of that problem?New feature What changes do you think we should make in order to solve the problem?
App/src/components/Form/FormWrapper.tsx Line 125 in 37105a1
Optional: If we don't want to apply for all forms of input, we can introduce a new prop in What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?What alternative solutions did you explore? (Optional)Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job. |
@bernhardoj I love your idea using But I have some question:
|
now we are using the high version react-router-dom, |
Updated to handle this case
I think the only option we have is to disable the swipe gesture or update the navigation to 7.0 and use |
PR is ready cc: @ahmedGaber93 |
This issue has not been updated in over 15 days. @abekkala, @ahmedGaber93, @stitesExpensify, @bernhardoj, @dubielzyk-expensify eroding to Monthly issue. P.S. Is everyone reading this sure this is really a near-term priority? Be brave: if you disagree, go ahead and close it out. If someone disagrees, they'll reopen it, and if they don't: one less thing to do! |
Deployed to staging |
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.82-12 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-17. 🎊 For reference, here are some details about the assignees on this issue:
|
BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
|
BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:
Regression Test Proposal
|
PAYMENT SUMMARY FOR JAN 17
|
@ahmedGaber93 irt to the regression step proposal. I feel like there should be a Step 19 which verifies the expected outcome |
Requested in ND. |
@abekkala steps from 3-17 already contain - Repeat step 3-17 but for Merchant field
+ Repeat the same test (step 3-17) for Merchant field and Verify it has the same behavior in steps 5, 9, 11, 14, 17. Updated! |
this got a little buried so I'll paste again for better visibility: PAYMENT SUMMARY FOR JAN 17
|
$250 approved for @bernhardoj |
$250 approved for @ahmedGaber93 |
Problem
When users fill in details in the app (e.g. description on an expense) and tap back or the scrim/overlay by mistake, the user loses everything they filled it. This can be particularly annoying if you submit an expense and fill in multiple details only to misclick and have to start over. We saw this multiple times during our usability study.
Solution
To remedy this, let's add a confirmation dialog on these sort of interactions by throwing up a confirmation dialog for unsaved changes. Here's a video to demonstrate:
CleanShot.2024-12-06.at.15.13.09.mp4
Notes:
Discard
continues the action of the user (if back, go back. If scrim/overlay, closer the right-hand-pane) without saving the value.Questions:
Submit expense
to try it out and continue from there.cc @Expensify/design @JmillsExpensify @trjExpensify
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @abekkalaThe text was updated successfully, but these errors were encountered: