DT-340: Warn the user if they are leaving a story edit page with unsaved changes#334
Merged
Merged
Conversation
torresga
marked this pull request as ready for review
November 7, 2024 20:30
JuanVqz
reviewed
Jan 10, 2025
JuanVqz
left a comment
Member
There was a problem hiding this comment.
My suggestions are not a blocker.
Member
|
Hey @torresga, this looks good; however, maybe we can improve a little bit on the
If you need help to follow the described steps, let me know, and we can check it together. |
JuanVqz
force-pushed
the
feature/DT-340-warn-user-unsaved-edits
branch
from
July 21, 2026 00:03
bf1c735 to
c6d99df
Compare
…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
Co-authored-by: Juan Vásquez <juan@ombulabs.com>
Co-authored-by: Juan Vásquez <juan@ombulabs.com>
- Track dirtiness by comparing the current form serialization to a snapshot taken on load, so reverting an edit (typing then deleting it) correctly clears the warning instead of leaving the form permanently 'dirty'. - Also listen for 'change' so status-select edits are detected, and guard the back/logo click handlers against missing elements on non-edit pages. - Add a feature spec covering the revert-to-original case.
JuanVqz
force-pushed
the
feature/DT-340-warn-user-unsaved-edits
branch
from
July 21, 2026 18:08
c6d99df to
9b2da29
Compare
JuanVqz
approved these changes
Jul 21, 2026
- Route every in-app link that leaves the edit page through one confirm with a single shared message constant, instead of hard-coding only Back and the logo. The native beforeunload prompt (reload / tab close) still uses the browser's own text, since browsers ignore custom strings there. - Initialize on turbolinks:load instead of DOMContentLoaded, matching project.js, so the guard (and the markdown preview) also initialize on Turbolinks visits. Module-scoped state lets the delegated click handler be added by reference and de-duplicated across visits.
Assert the cloned sub-projects by set of titles (contain_exactly) instead of positional index. The projects association has no default order, so indexing into it was order-dependent and failed on the build-rails-next lane when the database returned the rows in a different order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.