`select` elements change to first option on submit
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
If you have a select element inside a form and submit, it changes to the first available option.
Reproduction
https://stackblitz.com/edit/form-select-resetting?file=src%2Froutes%2F%2Bpage.svelte
- Start the dev server.
- Change the select value.
- Click "Submit"
Logs
N/A
System Info
System:
OS: Windows 11 10.0.26200
CPU: (28) x64 Intel(R) Core(TM) i7-14700K
Memory: 39.19 GB / 63.70 GB
Binaries:
Node: 24.16.0 - C:\Program Files\nodejs\node.EXE
npm: 11.7.0 - ~\AppData\Roaming\npm\npm.CMD
bun: 1.3.14 - ~\.bun\bin\bun.EXE
Browsers:
Edge: Chromium (149.0.4022.69)
Internet Explorer: 11.0.26100.8115
npmPackages:
@sveltejs/adapter-node: 5.5.5 => 5.5.5
@sveltejs/kit: 2.66.0 => 2.66.0
@sveltejs/vite-plugin-svelte: 7.1.2 => 7.1.2
svelte: 5.56.3 => 5.56.3
vite: 8.0.16 => 8.0.16
Severity
serious, but I can work around it
Additional Information
This happens regardless of the type of value used. So, this is similar to #15835, but not exactly the same. I intentionally used strings here in the linked reproduction to show that it happens even with strings.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked StackBlitz reproduction and follow the listed steps: run the dev server, change the select value, and submit the form. Trace the form submission and select handling in the reproduction and relevant SvelteKit code; done means the selected value remains unchanged after submission, with a regression test covering the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100