Repository navigation
fix(ui): stop losing unsaved edits when switching notes - #21
Merged
Merged
Conversation
Track whether the editor differs from the stored note and, before switching to another note or creating a new one, ask with Save / Discard / Cancel. Save only continues if it succeeded; Cancel and Escape stay on the current note. While there are pending changes, closing the tab is guarded with beforeunload. The new-note flow moves from NoteList to NotesApp so the guard runs before anything is created, otherwise cancelling would leave an orphan empty note. Closes #20
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.
Closes #20.
Switching notes silently discarded pending edits: the editor reset its title and content when the active note changed, with no dirty tracking and no warning. Reproduced before changing anything: type into a note, switch away, come back, the edit is gone.
Now the editor tracks whether it differs from the stored note, and switching notes or creating a new one asks with Save / Discard / Cancel. Save only continues if it succeeded; Cancel and Escape stay put. Closing the tab is guarded with
beforeunloadwhile changes are pending.The new-note flow moves from NoteList to NotesApp so the guard runs before anything is created on the server; otherwise cancelling would have left an orphan empty note (the bug fixed in #11).
Verification:
npm run buildandvue-tsc --noEmitpassbeforeunloadfires with a real user gesture, 0 JS errors