First input change after failed submit ignored with Next server actions
Describe the bug
In a form using Next server actions and validation after submitting an invalid input, the next character typed into the input is not shown. The input only shows from the second character on
Your minimal, reproducible example
https://stackblitz.com/edit/nextjs-dbp2u3qq?file=app%2Fexample-form.tsx
Steps to reproduce
- Press submit button
- Type a character into the input
Expected behavior
The first character typed should be seen in the input
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: MacOS
- Browser: Chrome and Firefox
TanStack Form adapter
react-form
TanStack Form version
1.12.2
TypeScript version
5.2.2 and 5.8.3
Additional context
No response
This is happening with the remix form as well. https://stackblitz.com/github/tanstack/form/tree/main/examples/react/remix?embed=1&theme=light&preset=node&file=src/index.tsx
Looking at the other issue mentioned regarding the similar issue, I believe this may help short term:
const form = useForm({
...formOpts,
transform: useTransform(
(baseForm) => {
if (!actionData) return baseForm;
const { values, ...serverState } = actionData;
return mergeForm(baseForm, serverState);
},
[actionData]
),
});