Skip to content

Commit c05a2c7

Browse files
committed
Reference fix in onResult
1 parent 355446c commit c05a2c7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1515

1616
- It wasn't possible to directly assign `undefined` to a field in the `$errors` store.
1717
- Intersections in Zod schemas weren't handled properly.
18+
- It wasn't possible to change the reference to the result in `onResult`.
1819

1920
## [2.7.0] - 2024-03-03
2021

src/lib/client/superForm.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ export function superForm<
17781778
currentRequest = null;
17791779

17801780
// Check if an error was thrown in hooks, in which case it has no type.
1781-
const result: ActionResult = event.result.type
1781+
let result: ActionResult = event.result.type
17821782
? event.result
17831783
: {
17841784
type: 'error',
@@ -1805,6 +1805,9 @@ export function superForm<
18051805
await event(data);
18061806
}
18071807

1808+
// In case it was modified in the event
1809+
result = data.result;
1810+
18081811
if (!cancelled) {
18091812
if ((result.type === 'success' || result.type == 'failure') && result.data) {
18101813
const forms = Context_findValidationForms(result.data);

0 commit comments

Comments
 (0)