Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture/Restore doesn't reset form with list of files correctly after submitting #386

Closed
1 task done
backstromjoel opened this issue Mar 21, 2024 · 3 comments
Closed
1 task done
Labels
bug Something isn't working

Comments

@backstromjoel
Copy link

backstromjoel commented Mar 21, 2024

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

Description
When submitting a form with a list of files, the list is still the same size as it was before submitting, but without any data.

Form definition...

const quoteForm = superForm(data.form, {
  validators: zodClient(optionalPartListSchema),
  dataType: 'json',
  onError(error) {
	  console.error(error);
	  errorMessage = $LL.SOMETHING_WENT_WRONG_DESCRIPTION({ reason: error.result.error.message });
	  errorOpen = true;
  },
  onSubmit: async ({ cancel }) => {
	  if ($form.parts.length === 0) {
		  errorMessage = $LL.MUST_ADD_PART_ALERT();
		  errorOpen = true;
		  cancel();
	  }
  }
});
const { form, capture, restore, enhance } = quoteForm;
export const snapshot = { capture, restore };

This is the form after submitting and routing back.
image

Expected behaviour is for the list to be reset to not contain any elements.

@backstromjoel backstromjoel added the bug Something isn't working label Mar 21, 2024
@ciscoheat
Copy link
Owner

What does the schema look like? It can be difficult for the array itself to reset, as the files are nested in the contents of the array. I can surely remove File objects recursively, and arrays containing files, but nested data that should be removed based on its content will probably require some manual work, in a custom capture function.

@ciscoheat
Copy link
Owner

At least the removal of File objects from snapshots is added now with 2.11.0, but I'm not sure if that solves your problem entirely?

@backstromjoel
Copy link
Author

The fixes in 2.11.0 fixed our issues! Thanks a lot, appriciate the ultra fast fix ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants