[Frontend] Shelf tonight-notes: the auto-save debounce is cancelled on unmount without flushing #536
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found while doing #464.
TonightNotesinwebapp/frontend/src/pages/SessionShelf.jsx(around lines 234–236) auto-saves on a 1.5 s debounce (#410) and clears the pending timer on unmount without flushing it. Navigating away within 1.5 s of the last keystroke therefore loses those characters today: the timer is cancelled, the save never fires, and nothing asks.Adding the new in-app prompt (
useUnsavedChangesPrompt, #464) there would only surface the loss, not prevent it: accepting the confirm still discards. The right fix is to flush the pending save on unmount (and onbeforeunload, withnavigator.sendBeaconor a synchronous path if the API allows), after which the prompt becomes near-unreachable on that field and is not needed.Severity: low in practice (the window is 1.5 s, the field is a GM's live notes), but it is a genuine data-loss path in a milestone line whose promise is that data is never lost.
Acceptance:
TonightNoteswith a pending debounce writes the pending text before the component goes away.BeatNotesEditor(:59) is a straightforward candidate foruseUnsavedChangesPromptif wanted; decide in the same change.