Skip to content

fix(ui): stop losing unsaved edits when switching notes - #21

Merged
gnacho merged 1 commit into
mainfrom
fix/issue-20-unsaved-changes-guard
Sep 13, 2026
Merged

gnacho merged 1 commit into
mainfrom
fix/issue-20-unsaved-changes-guard

Conversation

@gnacho

@gnacho gnacho commented Sep 13, 2026

Copy link
Copy Markdown
Owner

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 beforeunload while 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 build and vue-tsc --noEmit pass
  • Browser walkthrough with Playwright: Cancel keeps the content, Discard drops it, Save persists it, New note while dirty plus Cancel creates nothing, deleting a note still shows only its own dialog, beforeunload fires with a real user gesture, 0 JS errors

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
@gnacho
gnacho merged commit 06ede57 into main Sep 13, 2026
@gnacho
gnacho deleted the fix/issue-20-unsaved-changes-guard branch September 13, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn about unsaved changes before switching notes

1 participant