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

Form resets unexpectedly when inside Dialog on first validation failure #776

Closed
Merott opened this issue Sep 18, 2024 · 0 comments
Closed

Comments

@Merott
Copy link

Merott commented Sep 18, 2024

I've managed to narrow down the issue quite a bit, which makes this completely obsolete and confusing. I'm closing this in favour of #777.

See old issue details:

Describe the bug and the expected behavior

When a form that's been wired up with @conform-to/react is placed inside a Dialog component (tested with Radix UI and Headless UI), the form unexpectedly resets to its initial value upon the first validation failure. This only occurs the first time validation fails; subsequent validation failures don't cause the form to reset.

Expected behaviour: The form should maintain its current state and display validation errors without resetting to the initial value.

Conform version

v1.2.1

Steps to Reproduce the Bug or Issue

  1. Open the CodeSandbox demo
  2. In the Dialog, try entering a non-numeric value in the input field (eg. "abc")
  3. Click outside the input field to trigger validation
  4. Notice the input resets to its initial value of '123'
  5. Try entering a non-numeric value again
  6. Notice that now the form maintains the invalid input without resetting

To try the same without a dialog, find this line inside App.tsx and set placeInsideDialog to false:

const placeInsideDialog = true;

What browsers are you seeing the problem on?

Chrome, Firefox, Safari

Screenshots or Videos

Form inside a dialog:

CleanShot.2024-09-18.at.22.57.21.mp4

Exact same form outside the dialog:

CleanShot.2024-09-18.at.22.55.39.mp4
@Merott Merott closed this as not planned Won't fix, can't repro, duplicate, stale Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant