Skip to content

Form inside $derived() with use:enhance is removed from the DOM #634

@sillvva

Description

@sillvva
  • Before posting an issue, read the FAQ and search the previous issues.

Description

Even if I cancel the submit in onSubmit, to call a remote function instead, it is still calling this method to remove the form from the DOM. So if I return errors instead of redirecting, all the user sees is an empty page where the form used to be.

function EnhancedForm_destroy() {
if (EnhancedForm?.parentElement) {
EnhancedForm.remove();
}
EnhancedForm = undefined;
}

This is called in onDestroy, which triggers if you put superForm(...) inside $derived() and either call invalidateAll() or otherwise unmount the page in some way.

If applicable, a MRE
You may need to refresh the content window once to see the issue occur.
https://www.sveltelab.dev/l4x79459y8yei54

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions