fix(fluentui): re-read a field's configuration when the rendered field changes (#335) - #336
Merged
Merged
Conversation
…-adapter-caches-field-confi # Conflicts: # FormCraft.ForFluentUI/Fields/LookupField/FluentUILookupFieldComponent.razor.cs # README.md
phmatray
marked this pull request as ready for review
August 13, 2026 13:42
This was referenced Aug 13, 2026
Open
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.
Implements #335.
Closes #335.
#298/#308 fixed field-configuration staleness for MudBlazor; the Fluent UI adapter still has it — twelve components under
FormCraft.ForFluentUI/Fields/read their configuration inOnInitializedand never look again, so an instance re-parameterised with a differentContextkeeps rendering the previous field's settings.Rather than copy the mechanism a second time, this moves it down:
FieldConfigurationTrackerand theOnFieldConfigurationChanged()hook go toFieldComponentBaseinFormCraftcore (they reference no UI type), both adapters inherit it, and MudBlazor's three local wirings — it needed one per component hierarchy — collapse to zero.Executing the implementation plan task-by-task; the checklist below — and the plan on the issue — are ticked as each task lands. Opened as a draft — will be marked ready after the final task and a code-review pass.
Plan
Code review
A
highreview ofdev...HEADfound that the derived-state half of the hook's own contract had been under-applied across the Fluent components — and made the sharper point that the two adapters had already drifted on the very behaviour this PR moves to core to keep aligned, because the MudBlazor counterparts were solved correctly under #298. All fixed inbdf18bd:_displayTextin the hook was right for staleness and catastrophic alone: nothing else in the Fluent lookup repopulates it from the model. The MudBlazor lookup gets away with clearing because itsOnParametersSetcallsUpdateDisplayText()every render and repairs the blank on the same pass — the Fluent one has no such call, so a field with a perfectly good stored value rendered empty for ever. The hook now re-derives the text. Pinned byLookupField_Should_Keep_Displaying_Its_Value_After_A_Configuration_Swap, verified to fail against the clear-only version._selectedItemsacross a field change — a subsequent pick appended to the previous field's rows, so the display read "old, old, new" andPublishSelectionAsyncwrote the previous field's values into the new field's model property. The MudBlazor LOV clears the same list for the same reason (Field components cache their configuration at init, so a reused instance renders the previous field's settings #298)._isOpen/_rows/_searchTextsurvived a swap._rowsis aList<object>, so clicking a leftover rowDynamicInvokes the new field's selectors against the old field's row object — anArgumentExceptionout of a click handler when the item types differ._optionsand_selectedOption, so two fields whose values compare equal but whose labels differ left the previous field's label on screen./// <inheritdoc />and a comment referring to anOnInitializedthat no longer exists.Follow-ups
Min/Max/StepreachFluentNumberInputthrough an@attributessplat, and Blazor retains a component parameter that a later render stops supplying — so omitting the key is not the same as unsetting it, even though FormCraft's dictionary is now correct. Expressing "unset" means FormCraft supplying Fluent's own defaults (int.MinValue) explicitly, i.e. binding the bounds as real parameters rather than splatting a dictionary. That is a change to how the Fluent numeric components are written, soNumericField_Should_Rebind_Its_Min_When_The_Configuration_Is_Swappedswaps one bound for another and the omission case is left for its own issue. The MudBlazor adapter has the same shape viaMudTextField.Mask(noted under fix(mudblazor): re-read a field's configuration when the rendered field changes (#298) #308).