MudBaseInput: Use ParameterState for Text#12259
Merged
ScarletKuro merged 12 commits intodevfrom Dec 13, 2025
Merged
Conversation
Co-authored-by: ScarletKuro <[email protected]>
- Add TextChanged event firing in OnTextParameterChangedAsync for non-child-originated changes - Call UpdateValuePropertyAsync instead of SetValueAsync to preserve Autocomplete behavior - Set _validated and Touched flags in the handler - This fixes 7 out of 9 failing tests Co-authored-by: ScarletKuro <[email protected]>
Copilot
AI
changed the title
[WIP] Fix failing tests for MudBaseInput parameter state
MudBaseInput: Use ParameterState for Text
Dec 12, 2025
Add fallback chain for InputElementId to handle synchronous test scenarios where ParameterState may not be fully initialized yet. This ensures the component ID is available even before OnInitializedAsync completes. Co-authored-by: ScarletKuro <[email protected]>
- Fix MudAutocomplete.OnInitializedAsync calling base.OnInitialized() instead of await base.OnInitializedAsync() - this was breaking the entire initialization chain - Fix MudSelect.SetCustomizedTextAsync to use SetTextAsyncRaw instead of manually firing TextChanged, eliminating duplicate event firing - Remove InputElementId fallback logic as it's no longer needed after initialization fix All tests now pass: 4132 passed, 0 failed, 5 skipped Co-authored-by: ScarletKuro <[email protected]>
Member
|
@copilot I think that API should just turn into And for the current |
…tAndUpdateValueAsync - SetTextAsync(string? text) now directly calls _textState.SetValueAsync(text) - simple text setter - SetTextAndUpdateValueAsync(string? text, bool updateValue = true) is the renamed version with validation and update logic - Updated all call sites in MudInput, MudAutocomplete, MudSelect, MudRangeInput, MudMask, MudTextField, MudNumericField, and MudBaseInput - Note: MudPicker hierarchy (DatePicker, ColorPicker, TimePicker) has its own SetTextAsync that is unrelated to MudBaseInput All tests passing: 4132 passed, 0 failed, 5 skipped Co-authored-by: ScarletKuro <[email protected]>
Contributor
Author
Done! Renamed the API methods:
Updated all call sites across MudInput, MudAutocomplete, MudSelect, MudRangeInput, MudMask, MudTextField, MudNumericField, and MudBaseInput. Note: MudPicker hierarchy (DatePicker, ColorPicker, TimePicker) has its own unrelated All tests passing. Commit: 02251de |
The handler should NOT manually fire TextChanged when parent sets Text parameter. This violates two-way binding semantics: - When child calls _textState.SetValueAsync(), ParameterState automatically fires TextChanged (via .WithEventCallback) - When parent sets Text parameter, OnTextParameterChangedAsync fires but should only handle side effects (updating Value from Text), NOT fire TextChanged back to parent Removed test Autocomplete_Should_HaveValueWithTextChangedEvent as it was testing incorrect behavior (expecting TextChanged to fire when parent programmatically sets Text parameter). This follows the same pattern as MudSelect's OnSelectedValuesChangedAsync handler which also doesn't manually fire the Changed event. Co-authored-by: ScarletKuro <[email protected]>
This was referenced Feb 23, 2026
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.
Converts the
Textparameter in MudBaseInput to use the ParameterState framework, following the pattern established in PR #12244 for MudSelect.Changes
Core Implementation:
_textStateParameterState field withOnTextParameterChangedAsynchandlerTextparameter with[ParameterState]attributeTextChangedfromEventCallback<string>toEventCallback<string?>ReadTextproperty to access state valueSetTextAsync(string? text)method for simple text updates that directly calls_textState.SetValueAsync(text)SetTextAsync(string? text, bool updateValue = true)toSetTextAndUpdateValueAsync(string? text, bool updateValue = true)for text updates with validation and value update logicSetParametersAsyncParameterState Event Handling:
The
OnTextParameterChangedAsynchandler follows proper two-way binding semantics:UpdateValuePropertyAsync(false)to preserve derived component behavior (Autocomplete menu opening, coercion, etc.)_validatedandTouchedflagsTextChanged- the ParameterState framework automatically fires this via.WithEventCallback(() => TextChanged)when the child calls_textState.SetValueAsync()Component Updates:
ReadTextinstead of directTextaccessSetTextAsyncfor simple text setting orSetTextAndUpdateValueAsyncfor text setting with validation and value updatesReadTextBug Fixes:
MudAutocomplete.OnInitializedAsyncwherebase.OnInitialized()was called instead ofawait base.OnInitializedAsync(), which was breaking the component initialization chainMudSelect.SetCustomizedTextAsyncto useSetTextAsyncinstead of manually firingTextChanged, eliminating duplicate event firing with ParameterStateAPI Changes
New Method Names:
SetTextAsync(string? text)- Simple text setter that calls_textState.SetValueAsync(text)SetTextAndUpdateValueAsync(string? text, bool updateValue = true)- Text setter with validation, touched flag, and optional value updateThis naming better reflects the purpose of each method and follows the existing pattern of
UpdateTextPropertyAsyncandUpdateValuePropertyAsync.Test Results
Checklist:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.