Skip to content

Delayed async onSubmit form cancel doesn't reset #520

@Pandoks

Description

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

Description
A clear and concise description of what the bug is, and, unless obvious, what you expected instead.

    onSubmit: async (form) => {
      const { challengeId, credentialId, signature, authenticatorData, clientDataJSON } =
        await authenticatePasskey();

      if (!challengeId || !credentialId || !signature || !authenticatorData || !clientDataJSON) {
        form.cancel();
        return;
      }

      passkeyForm.form.set({
        usernameOrEmail: get(passkeyForm.form).usernameOrEmail,
        credentialId: credentialId || '',
        challengeId: challengeId || '',
        signature: signature || '',
        encodedAuthenticatorData: authenticatorData || '',
        clientDataJSON: clientDataJSON || ''
      });
    }
...
  const {
    form: passkeyFormData,
    enhance: passkeyEnhance,
    delayed: passkeyDelayedForm
  } = passkeyForm;

$passkeyDelayedForm doesn't reset when you cancel inside the async onSubmit function.

await authenticatePasskey() pops up a prompt for the user and waits for their input. When the user inputs their information quickly, $delayed will get reset. If the user takes too long though and the form is canceled, the $delayed won't reset giving me an infinite loading state.

I verified that with every interaction that it is making it into the if block:

if (!challengeId || !credentialId || !signature || !authenticatorData || !clientDataJSON) {
        form.cancel();
        return;
      }

When I print the output of $passkeyDelayedForm after the form.cancel() however, it says that it's true when there is a long enough delay. It will print false if it's done quickly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions