Skip to content

Commit

Permalink
In rare cases, timers weren't resetted when redirecting to the same r…
Browse files Browse the repository at this point in the history
…oute.
  • Loading branch information
ciscoheat committed Aug 9, 2023
1 parent f4feaea commit 8c22a48
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Headlines: Added, Changed, Deprecated, Removed, Fixed, Security
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.5.1] - 2023-08-09

### Fixed

- In rare cases, timers weren't resetted when redirecting to the same route.

## [1.5.0] - 2023-07-23

### Fixed
Expand Down
13 changes: 12 additions & 1 deletion src/lib/client/formEnhance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,9 +477,20 @@ export function formEnhance<T extends AnyZodObject, M>(
cancelFlash(options);
}

// Redirect messages are handled in onDestroy and afterNavigate.
// Redirect messages are handled in onDestroy and afterNavigate in client/form.ts.
// Also fixing an edge case when timers weren't resetted when redirecting to the same route.
if (cancelled || result.type != 'redirect') {
htmlForm.completed(cancelled);
} else if (
result.type == 'redirect' &&
new URL(
result.location,
/^https?:\/\//.test(result.location)
? undefined
: document.location.origin
).pathname == document.location.pathname
) {
htmlForm.completed(true);
}
}

Expand Down

0 comments on commit 8c22a48

Please sign in to comment.