ui: useUnsavedChanges does not guard param-only route changes #91

Open
opened 2026-09-16 01:13:36 +00:00 by pienter · 0 comments
Owner

Follow-up to #51 (PR #90).

useUnsavedChanges (packages/ui/composables/useUnsavedChanges.ts) registers onBeforeRouteLeave, which only fires when the route record changes. A param-only navigation on the same record, for example editing /pages/1/edit in the address bar to /pages/2/edit, stays on the record: the guard never asks, the form's load() runs and silently replaces a dirty model. Query changes such as a company view's ?tab= are not affected, since they are not leaves either and do not reload the model.

No in-app link does this today, so it is an edge case rather than a regression.

Proposal: the composable also registers onBeforeRouteUpdate(() => confirmLeave()), so a param change asks the same question through the same AlertDialog. Document it in the composable's JSDoc and the RecordForm AUDIT.

Follow-up to #51 (PR #90). `useUnsavedChanges` (`packages/ui/composables/useUnsavedChanges.ts`) registers `onBeforeRouteLeave`, which only fires when the route record changes. A param-only navigation on the same record, for example editing `/pages/1/edit` in the address bar to `/pages/2/edit`, stays on the record: the guard never asks, the form's `load()` runs and silently replaces a dirty model. Query changes such as a company view's `?tab=` are not affected, since they are not leaves either and do not reload the model. No in-app link does this today, so it is an edge case rather than a regression. Proposal: the composable also registers `onBeforeRouteUpdate(() => confirmLeave())`, so a param change asks the same question through the same `AlertDialog`. Document it in the composable's JSDoc and the RecordForm AUDIT.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pienter/ui#91
No description provided.