dokploy icon indicating copy to clipboard operation
dokploy copied to clipboard

Bug: add-invitation form resets state on API error but leaves Select component visually out of sync

Open imrja8 opened this issue 2 months ago • 1 comments

To Reproduce

  1. Log in to Dokploy as an Admin or Owner (or a user with permissions to create users).
  2. Go to the Dokploy dashboard and navigate to /dashboard/settings/users.
  3. Under the "Invitations" section, click the "+ Add Invitation" button.
  4. In the "Invite Method" dropdown, select "Initial Credentials".
  5. Enter an email address of a user that already exists in the system (e.g. [email protected]).
  6. Fill out the password fields and click "Create".
  7. Notice the popup shows a correct error toast: "This email already has an account. Use the invitation link flow for existing users."
  8. However, observe that the form dynamically switches to display the fields for the "Invitation Link" flow (e.g., Email Provider), but the "Invite Method" dropdown visually remains stuck on "Initial Credentials".

Current vs. Expected behavior

Current Behavior: When the API returns an error during the initial credentials flow, the form's internal state is reset to "invitation" (due to react-hook-form treating the submission as successful because the error was caught and not re-thrown). This reveals the "Invitation Link" fields. However, the Radix UI Select component for the Invite Method doesn't update its visual label because it uses defaultValue={field.value} instead of value={field.value}, leaving it visually out of sync with the actual form state.

Expected Behavior: The form should not reset and switch modes when an API error occurs, allowing the user to correct their input and submit again. Alternatively, if the form must reset, the "Invite Method" select component should correctly update visually to reflect the reset state (by using value={field.value}).

Provide environment information

Operating System:
  OS: Ubuntu 24
  Arch: amd64 (x86_64)
Dokploy version: 0.30.7
VPS Provider: AWS EC2 (c8a.8xl)

Which area(s) are affected? (Select all that apply)

  • [x] Application

Are you deploying the applications where Dokploy is installed or on a remote server?

  • [x] Same server where Dokploy is installed (N/A to this UI bug)

Additional context

This bug is located in apps/dokploy/components/dashboard/settings/users/add-invitation.tsx.

Two factors causing the issue:

  1. onSubmit catches the error but doesn't rethrow it, so isSubmitSuccessful is flagged true by react-hook-form, triggering form.reset() in the useEffect.
  2. The <Select> element for name="mode" uses defaultValue={field.value} instead of value={field.value} making it an uncontrolled component that does not react to the form.reset().

Will you send a PR to fix it?

  • [x] Yes
  • [ ] No

imrja8 avatar Sep 21 '26 09:09 imrja8

DOK-788

linear-code[bot] avatar Sep 21 '26 09:09 linear-code[bot]