Inputs: Fix validation on programmatic value change#12892
Conversation
- Create view and unit test to make sure the error message will show after updating the input value via programation - Fix the MudBaseInput OnValueParameterChangedAsync to trigger the FiedlChange and BeginValidateAsync fixing the issue MudBlazor#12012
There was a problem hiding this comment.
Pull request overview
This PR addresses a regression where MudBaseInput did not re-evaluate validation state when the bound Value parameter is updated programmatically (#12012), ensuring form errors clear/reappear appropriately after code-driven updates.
Changes:
- Trigger
FieldChanged+BeginValidateAsyncwhenValuechanges via parameter updates inMudBaseInput. - Add a unit test to validate error state transitions when
Valueis set via parameter binding. - Add a UnitTests.Viewer repro component demonstrating the programmatic update scenario with FluentValidation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/MudBlazor/Base/MudBaseInput.cs |
Revalidates and notifies form on parent-driven Value parameter changes. |
src/MudBlazor.UnitTests/Components/FormTests.cs |
Adds regression test for clearing/restoring validation errors after programmatic value updates. |
src/MudBlazor.UnitTests.Viewer/TestComponents/Form/FormValidationErrorClearedOnProgrammaticValueChangeTest.razor |
Adds a viewer repro component for the reported issue. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
…s://github.com/redgp0g/MudBlazor into fix/form-validation-not-reevaluated-issue12012
|
@versile2 what do you think? |
I think this part of the code base is not my expertise and I do not have adequate time to review/learn it. I believe @ScarletKuro is probably the most knowledgeable here. |
I don’t like the use of Feel free to prove me wrong whatever it's really necessary here. |
I totally agree with removing the |
Refactor field change notification to trigger only after the field has been touched.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you! |
video.mp4
Checklist: