Skip to content

[Wizard] fix: Validation does not work for child components #3713

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

Open
davhdavh opened this issue Apr 19, 2025 · 2 comments
Open

[Wizard] fix: Validation does not work for child components #3713

davhdavh opened this issue Apr 19, 2025 · 2 comments
Labels
needs: author feedback The author of this issue needs to respond in order for us to continue investigating this issue.

Comments

@davhdavh
Copy link

🐛 Bug Report

If you put the step in a separate component, validation stops working.

Even if EditEnabled contains the exact same code as in the first step, it validates 1 time, fails to show the actual error messages, and next time you click next it proceeds as if validation succeeded.

💻 Repro or Code Sample

  <FluentWizard>
   <Steps>
   <FluentWizardStep Label="Enable works">
    <FluentEditForm Model="@_demo">
     <DataAnnotationsValidator/>
      <FluentCheckbox @bind-Value="@_demo.Enabled" Label="TODO Enable" />
      <FluentValidationMessage For="@(()=>_demo.Enabled)" />
    </FluentEditForm>
   </FluentWizardStep>
    <FluentWizardStep Label="Enable fails">
     <EditEnabled Model="@_demo" />
    </FluentWizardStep>
   </Steps>
  </FluentWizard>

🤔 Expected Behavior

I can put each step in a sub component

😯 Current Behavior

Validate breaks when put in sub component

💁 Possible Solution

I have debugged it down to Dispose is called on DataAnnotationsValidator, cannot figure out why it gets disposed in the first place. The subcomponent itself does not gets disposed if you implement IDisposable.

@microsoft-github-policy-service microsoft-github-policy-service bot added the triage New issue. Needs to be looked at label Apr 19, 2025
@PascalVorwerk
Copy link
Contributor

I am not entirely sure without more code, but are you sure the steps are rendered whenever you step to another step? If the first step is not rendered anymore as you move to the 2nd step, then all the context and the data annotations validator might be disposed and not available in the second component?

For example.. how can the 2nd step reach the Cascading edit context of the first step if the EditForm is not wrapping that step?

@ApacheTech
Copy link
Contributor

I'm wondering whether this requires the use of <ObjectGraphDataAnnotationsValidator /> instead of <DataAnnotationsValidator/>. You can use [ValidateComplexType] to validate complex objects within the context.

Here's a reference guide: https://www.syncfusion.com/faq/blazor/forms-and-validation/how-do-i-validate-a-nested-complex-model-in-blazor

It's not a guaranteed fix, but it's usually my first port of call when dealing with nested validation issues.

@vnbaaij vnbaaij added needs: author feedback The author of this issue needs to respond in order for us to continue investigating this issue. and removed triage New issue. Needs to be looked at labels May 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: author feedback The author of this issue needs to respond in order for us to continue investigating this issue.
Projects
None yet
Development

No branches or pull requests

4 participants