ParameterState: Add ParameterView to ParameterChangedEventArgs#12269
Merged
ScarletKuro merged 4 commits intoMudBlazor:devfrom Dec 14, 2025
Merged
ParameterState: Add ParameterView to ParameterChangedEventArgs#12269ScarletKuro merged 4 commits intoMudBlazor:devfrom
ScarletKuro merged 4 commits intoMudBlazor:devfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the ParameterState framework by adding a ParameterView property to ParameterChangedEventArgs<T>, enabling change handlers to inspect related parameters that were set simultaneously. This addresses scenarios where components need to resolve dependencies between parameters (e.g., Text and Value in input components) and determine which should take precedence when both change at the same time.
- Added
ParameterViewproperty toParameterChangedEventArgs<T>to provide a snapshot of all parameters set during the change - Updated constructor to require
ParameterViewas the first parameter (breaking change to public API) - Added comprehensive test coverage to verify ParameterView is correctly passed and contains expected parameters
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/MudBlazor/State/ParameterChangedEventArgs.cs | Added ParameterView property and updated constructor signature to accept ParameterView as first parameter, including XML documentation |
| src/MudBlazor/State/ParameterStateInternalOfT.cs | Updated instantiation of ParameterChangedEventArgs to pass the ParameterView parameter |
| src/MudBlazor.UnitTests/State/ParameterStateTests.cs | Added new test verifying ParameterView contains multiple parameters and updated existing test assertions to include ParameterView |
| src/MudBlazor.UnitTests/State/ParameterScopeContainerTests.cs | Updated test assertions to include ParameterView in expected ParameterChangedEventArgs instances |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
14 tasks
Merged
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There is a need to inspect the
ParameterViewinside the change handler.In some components, MudBlazor components are a good example, there is a dependency between parameters such as
TextandValue. Typically,Valuerepresents a value of typeT, whileTextis its textual(string) representation.This creates bidirectional synchronization requirements:
Textchanges,Valuemay need to be updated.Valuechanges,Textmay need to be updated.However, both parameters can change at the same time. For example, an end user might use two-way binding for both
TextandValue. In such cases, the incoming values may already be consistent (e.g.,Valueand its correct textual representation), or they may conflict for some reason.At that point, the component must decide which parameter should take precedence.
Without access to
ParameterView, this decision becomes effectively impossible inside the change handler withParameterState. While it is theoretically possible to introduce boolean flags insideComponentBase.SetParametersAsyncto track changes, this approach is fragile, error-prone, and can easily lead to race conditions.Checklist: