Skip to content

feat(send): warn on tab close/refresh with unsaved transfer input (closes #456) - #558

Open
Vyacheslav-Tomashevskiy wants to merge 1 commit into
Northgate-Systems:mainfrom
Vyacheslav-Tomashevskiy:feat/456-unsaved-changes-warning
Open

Vyacheslav-Tomashevskiy wants to merge 1 commit into
Northgate-Systems:mainfrom
Vyacheslav-Tomashevskiy:feat/456-unsaved-changes-warning

Conversation

@Vyacheslav-Tomashevskiy

Copy link
Copy Markdown
Contributor

Closes #456.

What

Adds a "did you mean to leave?" browser confirm when someone tries to close the tab, refresh, or type a new URL while they have real input in the send form. Without this, a half-filled transfer just vanishes silently.

Where

  • src/hooks/useUnsavedChangesWarning.ts — new hook. Takes an isDirty boolean and wires/unwires a beforeunload listener that calls preventDefault() and sets event.returnValue (browsers ignore any custom message and render their own wording per the spec — setting the value is just what triggers the native prompt).
  • src/app/(app)/send/page.tsxisDirty is true once the recipient field has something typed in it, or the amount has been changed away from the page's own default (100.00). Just switching the asset dropdowns doesn't count as "input" worth warning about on its own.

Scope note

This only covers beforeunload — tab close, refresh, typed-URL navigation. It does not intercept in-app Link navigation (e.g. clicking something in the header/sidebar while the form is dirty), since the App Router doesn't expose a route-change guard for that today, and building one is a considerably bigger change than this issue's estimated 1-3h. Flagging this per the issue's own note about leaving a comment if the approach needs to narrow rather than silently changing scope.

Verification

  • npm run lint — clean on the changed files.
  • npm run build — Turbopack compile succeeds; the tsc step still fails, but only on the pre-existing, unrelated isValidStellarPublicKey import gap in src/lib/validations.ts (already flagged in fix(validations): restore broken isValidStellarPublicKey import; feat: add /api/stellar/fee-estimate #529 and prior PRs) — nothing in this PR touches that file.
  • Manually verified in the browser at desktop and mobile widths: typing into the recipient field or changing the amount and then hitting refresh brings up the browser's native "leave site?" prompt; with a clean/default form, refresh and navigation are silent as before.

…oses Northgate-Systems#456)

Add a beforeunload guard so closing the tab, refreshing, or typing a
new URL while the send form has real input doesn't silently drop a
half-filled transfer.

- src/hooks/useUnsavedChangesWarning.ts: new hook, takes an isDirty
  boolean and wires/unwires a beforeunload listener that calls
  preventDefault() + sets returnValue (browsers show their own
  wording regardless of the string, per spec).
- src/app/(app)/send/page.tsx: isDirty = recipient typed something
  or the amount was changed from the page's own default (100.00) --
  changing just the asset dropdowns alone doesn't count as 'input'
  worth warning about.

Scope note: this only covers beforeunload (tab close/refresh/typed
URL), not in-app Link navigation -- the App Router doesn't expose a
route-change guard for that, and adding one is a much bigger change
than this issue's estimated 1-3h.

Verified npm run lint clean on the changed files, npm run build
compiles (TypeScript step still fails only on the pre-existing,
unrelated isValidStellarPublicKey import gap in validations.ts,
same as flagged in Northgate-Systems#529 and prior PRs -- not touched here).
@vercel

vercel Bot commented Sep 11, 2026

Copy link
Copy Markdown

@Vyacheslav-Tomashevskiy is attempting to deploy a commit to the codex723's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Add form-level 'unsaved changes' warning on the send page

1 participant