-
Notifications
You must be signed in to change notification settings - Fork 14
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
DT-340: Warn the user if they are leaving a story edit page with unsaved changes #334
base: main
Are you sure you want to change the base?
Conversation
…r if there are unsaved edits
…from an unsaved edited story
…e form existed. Also created a function to add and remove the beforeunload event listener
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My suggestions are not a blocker.
if (!confirmLeave) { | ||
// Prevent navigation if the user chooses not to leave | ||
event.preventDefault(); | ||
} else { | ||
// Optionally, reset isDirty if leaving | ||
isDirty = false; | ||
addBeforeUnloadEventListener(isDirty) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it easier to read confirmLeave
compared to !confirmLeave
, as it always takes me a moment to grasp the condition.
if (!confirmLeave) { | |
// Prevent navigation if the user chooses not to leave | |
event.preventDefault(); | |
} else { | |
// Optionally, reset isDirty if leaving | |
isDirty = false; | |
addBeforeUnloadEventListener(isDirty) | |
} | |
if (confirmLeave) { | |
// Optionally, reset isDirty if leaving | |
isDirty = false; | |
addBeforeUnloadEventListener(isDirty) | |
} else { | |
// Prevent navigation if the user chooses not to leave | |
event.preventDefault(); | |
} |
} | ||
} | ||
|
||
function warnUserifUnsavedEdits(event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit picky, you might missed the I
should go in uppercase.
function warnUserifUnsavedEdits(event) { | |
function warnUserIfUnsavedEdits(event) { |
Jira Ticket
https://ombulabs.atlassian.net/browse/DT-340
Motivation / Context
Currently if you leave the current page, you can lose information that was not saved. This feature warns you if you are leaving without saving information.
QA / Testing Instructions
Screenshots:
I will abide by the code of conduct.