Conversation
Codecov Report
@@ Coverage Diff @@
## dev #4801 +/- ##
=======================================
Coverage 91.41% 91.42%
=======================================
Files 365 365
Lines 12542 12553 +11
=======================================
+ Hits 11465 11476 +11
Misses 1077 1077
Continue to review full report at Codecov.
|
|
@henon Is there anything you would like me to change here? |
|
I can see how this can be useful. The only thing I worry is that this event will cause a re-render of the whole form whenever the user changes something. It might cause unwanted effects or even slow down big forms. In general it can be dangerous for elements to cause render updates on their ancestors. In this light, can you make sure raising this event doesn't cause form re-renders when a user doesn't add a handler for this event? It might be this way already but we better check. For instance, in a testcase you can access the RenderCount property of a TestComponent.
We have a solution for that. You can check the Standalone cascading parameter of Textfield / Input. If Standalone is false you should not fire the event. You'll notice that the Standalone cascading parameter is already used to prevent internal Inputs to do validation.
I think a good doc string on the event is enough. |
I have confirmed no renders occur when no handler is assigned to I looked into optimizing the renders with ShouldRender as
Perfect, I have implemented this change and the double event trigger is resolved. |
Yeah |
Description
This PR adds a
FieldChangedevent to the MudForm. Example usage:It will fire whenever a
MudFormComponentvalue changes. I believe I have accounted for all components which inheritMudFormComponent.A few caveats:
MudFormComponentand are not covered by this PR.IForm, which means theFieldChangedmethod of that interface is ignored in the Table validators which inheritIForm. However, this was already the case for theUpdatemethod.One potential issue: MudTextFields trigger the event twice, once with a MudTextField type and once with a MudInput type.
Lastly, this seems like a niche change and I have not written proper documentation for it. However, I can do so if desired.
How Has This Been Tested?
I have written a unit test to cover the interaction with the most common fields and make sure the FieldChanged event fires correctly.
Types of changes
Checklist:
dev).