Skip to content

angrytongan/use-enhance-bug

Repository files navigation

use:enhance resets form data between repeated submits

Submitting the same form content when using use:enhance results in form fields being cleared between submits.

To reproduce

  1. Install
npm install
npm run dev
  1. Browse to http://localhost:5173

  2. Enter hello in first field, world in second field.

  3. Press Submit.

  4. hello world is printed underneath the form. First field contains hello, second field contains world. Server prints:

    { first: 'hello', last: 'world' }
  5. Press Submit.

  6. hello world is printed underneath the form. Fields are now empty. Server prints:

    { first: 'hello', last: 'world' }
  7. Press Submit.

  8. Nothing printed underneath form. Fields are empty. Server prints:

    { first: '', last: '' }

Expectation

Fields should never lose their content.

Use case

  • Chat form with room and message field: the room may not change, but the message does. We want to keep the room between form submits.

About

Sveltekit use:enhance bug code

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published