Skip to content

Commit ee80756

Browse files
committed
fix(skills): retire the in-app back guard on release too
release() suppressed the unload warning and the browser Back trap, but the in-app back link still keyed only on isDirty — so the Skills chip could open the unsaved-changes modal after a successful create, while the drafts were still populated and the navigation was already in flight.
1 parent 2228383 commit ee80756

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

apps/sim/app/workspace/[workspaceId]/components/credential-detail/hooks/use-unsaved-changes-guard.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ export function useUnsavedChangesGuard({ isDirty, backHref }: UseUnsavedChangesG
6565

6666
const handleBackClick = useCallback(
6767
(event: MouseEvent<HTMLAnchorElement>) => {
68-
if (isDirty) {
68+
if (isDirty && !isReleased) {
6969
event.preventDefault()
7070
setShowUnsavedAlert(true)
7171
}
7272
},
73-
[isDirty]
73+
[isDirty, isReleased]
7474
)
7575

7676
const confirmDiscard = useCallback(() => {
@@ -79,11 +79,12 @@ export function useUnsavedChangesGuard({ isDirty, backHref }: UseUnsavedChangesG
7979
}, [router, backHref])
8080

8181
/**
82-
* Retires the guard: no unload warning, no browser Back trap, and no pop of the
83-
* seeded entry when the form goes clean. Call it before navigating away on a
84-
* successful save, and navigate with `router.replace` so the seeded entry is the
85-
* one consumed. An operation that goes clean before it resolves (an optimistic
86-
* delete) must release up front and {@link rearm} if it fails.
82+
* Retires the guard: no unload warning, no Back trap (browser or the in-app back
83+
* link), and no pop of the seeded entry when the form goes clean. Call it before
84+
* navigating away on a successful save, and navigate with `router.replace` so the
85+
* seeded entry is the one consumed. An operation that goes clean before it
86+
* resolves (an optimistic delete) must release up front and {@link rearm} if it
87+
* fails.
8788
*/
8889
const release = useCallback(() => setIsReleased(true), [])
8990

0 commit comments

Comments
 (0)