kit
kit copied to clipboard
enhanced GET form does not submit values attached to `<button type="submit">`
Describe the bug
If you have the following form:
<form>
<button type="submit" name="foo" value="bar">Submit</button>
</form>
Submitting it with JavaScript disabled includes the foo value, i.e. the URL contains ?foo=bar. This is native browser behavior. With JS enabled, SvelteKit overrides the default submit behavior and does not submit the foo value -- form data attached to submit buttons is not included.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-yfd4dm?file=src/routes/+page.svelte
Logs
No response
System Info
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 16.14.2 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 7.17.0 - /usr/local/bin/npm
npmPackages:
@sveltejs/adapter-auto: ^1.0.0 => 1.0.0
@sveltejs/kit: ^1.0.0 => 1.0.1
svelte: ^3.54.0 => 3.55.0
vite: ^4.0.0 => 4.0.3
Severity
serious, but I can work around it
Additional Information
No response
I think we need this bit from the default enhance action, but applied to the GET form submit listener:
https://github.com/sveltejs/kit/blob/30e1130ef84e56a77be5cb1136d5c53edef6e5f9/packages/kit/src/runtime/app/forms.js#L74-L77
The same goes for input[type=submit]
<form>
<input type="submit" name="foo" value="bar" />
</form>