MudFormComponent: Fix validation handling (#9215)#9386
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #9386 +/- ##
==========================================
+ Coverage 89.82% 90.59% +0.76%
==========================================
Files 412 403 -9
Lines 11878 12669 +791
Branches 2364 2448 +84
==========================================
+ Hits 10670 11478 +808
+ Misses 681 632 -49
- Partials 527 559 +32 ☔ View full report in Codecov by Sentry. |
henon
left a comment
There was a problem hiding this comment.
Thanks, this change seems to make a lot of sense
|
Before I merge it, do we need any notes on little behavior change for migration guide or not or we just consider it as bug fix? |
|
I'd argue this is a bug fix. However I suggested a clarification note in the docs of |
|
Thanks! |
|
Will this fix an issue we're seeing with Mud input components that have Required=true within an EditForm (not MudForm) with a custom validator? Anything with required=true pops up a validation error rather than running our own fluent validator which does more conditional validation (and could skip required fields in certain instances)? |
I would say the best thing is to try it out. It's part of MudBlazor starting from version 7.2.0. |
|
Hmm, didn't realise it was already in release, in which case, it does not. I'll need to raise a bug. |
I don't think it will, based on my knowledge. When you set |
Not sure if it's even possible to fix tho. |
|
I think you can try to add the |
OK, I guess with v7, MudBlazor adds the required HTML tag where previously it didn't (and just appended * to the label to denote required). Looks like adding the novalidate overrides the native handing of required. Thanks for the help! |
Description
Fixes validation handling in
MudFormComponent:EditContextbecause all generated validation messages will get overwritten byOnValidationStateChangedonce the validation handler of theEditContextis updating the validation state. This also prevents 'double validation' and possible issues with custom validators that might get executed twice and as a bonus there is a minimal performance gain as unneeded code parts are skipped.Fixes #9215
How Has This Been Tested?
All existing unit tests have passed and manual testing of the forms section in MudBlazor.Docs.Server has been done.
Type of Changes
Checklist
dev).