Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-preflight-stale-issues.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: clear stale preflight issues on subsequent valid form submissions
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ export function form(id) {
return;
}

// Preflight passed - clear stale client-side preflight issues
if (preflight_schema) {
raw_issues = raw_issues.filter((issue) => issue.server);
}

// TODO 3.0 remove this warning
if (DEV) {
const error = () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { tick } from 'svelte';
import { get_number, set_number } from './form.remote.js';
import * as v from 'valibot';

Expand Down Expand Up @@ -35,6 +36,10 @@
<form
data-enhanced
{...enhanced.preflight(schema).enhance(async ({ submit }) => {
await tick();
if (enhanced.fields.number.issues()) {
return;
}
await submit();
})}
>
Expand Down
16 changes: 13 additions & 3 deletions packages/kit/test/apps/async/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,26 @@ test.describe('remote functions', () => {
await page.goto('/remote/form/preflight');

for (const enhanced of [true, false]) {
const input = page.locator(enhanced ? '[data-enhanced] input' : '[data-default] input');
const form = page.locator(enhanced ? '[data-enhanced]' : '[data-default]');
const input = form.locator('input');
const button = page.getByText(enhanced ? 'set enhanced number' : 'set number');

await input.fill('21');
await button.click();
await page.getByText('too big').waitFor();
await form.getByText('too big').waitFor();

await input.fill('9');
await button.click();
await page.getByText('too small').waitFor();
await form.getByText('too small').waitFor();
await expect(form.getByText('too big')).not.toBeVisible();

if (enhanced) {
// one more time preflight-issue only so that we can test it's cleared
// after it passes and before submission.
await input.fill('21');
await button.click();
await form.getByText('too big').waitFor();
}

await input.fill('15');
await button.click();
Expand Down
Loading