Conversation
Fixed once in FieldComponentBase.IsDisabled, the seam every component of both adapters binds Disabled to; FormCraftComponent never feeds a per-field Disabled parameter, so the planned per-adapter site had nothing to plug into. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s-never-evaluated
phmatray
marked this pull request as ready for review
September 24, 2026 08:41
This was referenced Sep 24, 2026
phmatray
added a commit
that referenced
this pull request
Sep 24, 2026
…#487) * fix(mudblazor): bind IsDisabled to the single-file upload component MudBlazorFileUploadFieldComponent never bound Disabled, so .Disabled()/ .DisabledWhen(...) had no effect: MudFileUpload, the Browse button, and the Clear button stayed active. Bind Disabled="@IsDisabled" on all three, and guard OpenFilePickerAsync() directly since the MudPaper drop zone's @OnClick calls it without going through any Disabled-bound control. Follow-up from #479. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(mudblazor): bind IsDisabled to the multiple-file upload component MudBlazorMultipleFileUploadComponent had the same gap as the single-file component: Disabled was never bound, so .Disabled()/.DisabledWhen(...) left MudFileUpload, Browse and Clear All active. Bind Disabled="@IsDisabled" on all three, guard OpenFilePickerAsync() for the same drop-zone reason as the single-file component, and guard RemoveFile(...) since a file chip's close callback is FormCraft's own CustomContent and no Disabled binding reaches it. Follow-up from #479. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * test(mudblazor): cover the drop-zone click path for disabled file uploads Both OpenFilePickerAsync() guards were untested: the Browse button's own Disabled binding already blocks a click there, so the only path that exercises the guard is the MudPaper drop zone's own @OnClick, which calls OpenFilePickerAsync() directly. Add one fact per component with a positive control (enabled: the click does open the picker) before the negative (disabled: it does not), so a wrong selector cannot pass silently. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> * fix(mudblazor): guard SetDragClass against a disabled file-upload field Review of #482 found the same bypass in SetDragClass() that OpenFilePickerAsync already guarded: @ondragenter is FormCraft's own MudPaper handler, not gated by MudFileUpload's Disabled, so a disabled field still showed drag-hover feedback (the highlight class, the transparent capture input unhidden) even though the actual drop is already blocked at the MudBlazor layer. Also adds the one direct assertion the new tests were missing: the single-file Clear button's Disabled binding with a file already present. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
phmatray
added a commit
that referenced
this pull request
Sep 24, 2026
…#483) (#489) * fix(core): resolve DisabledCondition in the core stub field renderers The seven core stub renderers under FormCraft/Forms/Rendering/ read Context.Field.IsDisabled directly, so .DisabledWhen(...) had no effect on the no-adapter-registered fallback path even though FieldComponentBase.IsDisabled already resolves it correctly for both UI adapters (#479). Apply the same expression here: Context.Field.DisabledCondition?.Invoke(Context.Model) ?? Context.Field.IsDisabled Also stub IFieldConfiguration.DisabledCondition to null in the existing Fake-based test helpers across these seven test files: FakeItEasy returns a dummy Func<TModel,bool> (not null) for an unconfigured delegate property, and invoking it returns false, which was silently overriding an explicitly stubbed IsDisabled=true once the renderers started reading DisabledCondition first. Closes #483 * test(core): replace internal-state assertions with rendered-DOM checks FileUploadFieldRendererTests had two pre-existing assertions that checked internal state rather than rendered output (out of scope for #478/#486, which targeted ShouldNotBeNull()): - Render_WithMultipleFilesConfiguration_ConfiguresForMultipleUpload asserted uploadConfig.Multiple.ShouldBeTrue() — an Arrange-time fact about the config object, not the rendered DOM. Replaced with a DOM assertion that "accept" stays absent, consistent with the sibling tests' documented fact that this stub never reads FileUploadConfiguration. - Render_ClearsValidationErrors_OnSuccessfulUpload asserted additionalAttributes.ShouldNotContainKey("FileUploadErrors") against a dict the renderer never touches. Replaced with a DOM assertion that "multiple" stays absent, matching the same fixed-markup fact already established in the file's other CurrentValue-driven tests. Closes #488 * fix: address code-review findings - FileUploadFieldRendererTests: give the two rendered-DOM replacement assertions (#488) something real to pin instead of proving "nothing is emitted from nothing" — set AcceptedFileTypes on the FileUploadConfiguration the "accept" assertion checks against, and stub ActualFieldType so the "multiple" assertion actually reflects a single-file scenario. - CoreRendererDisabledWhenTests: assert the file-upload facts render an <input type="file"> in addition to the disabled state, so a future regression that accidentally resolved a different renderer for the field would be caught rather than silently asserting on the wrong element.
This was referenced Sep 28, 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.
Implements #476.
Closes #476.
.DisabledWhen(...)stored its condition onIFieldConfiguration.DisabledCondition, but nothing ever evaluated it. Every field component in both adapters bindsDisabled="@IsDisabled"fromFieldComponentBase, which read only the staticIsDisabledflag.Why this deviates from the plan's fix site. The plan put the check in each adapter's
FormCraftComponent.razor.cs, next toVisibilityCondition. That spot has nothing to plug into: visibility gates whether a field renders (an@if), butFormCraftComponentnever passes a per-fieldDisabledparameter. The seam both adapters actually go through isFieldComponentBase.IsDisabled, which the Spec's "minimal core seam they both call through" clause allows. The fix is one line there:.Disabled(bool), asIFieldConfiguration's doc comment already said.Tests. A
DisabledWhenRenderingTestsclass in each adapter suite, with 4 facts each:false → true → false.Disabled()flag still works without a conditionWithout the fix, 3 of the 4 fail in each adapter. Full suite: 2075/2075 green on the tree merged with
dev;dotnet format --verify-no-changesis clean.Focus (CLAUDE.md 2.4.3): not triggered. The control that becomes disabled is the dependent field, not the one being activated. A caller who writes a condition on a field's own value could make it disable itself, but that is the same configuration
VisibleWhenalready allows.Plan
DisabledConditioninto MudBlazor's render pass and prove itDisabledConditioninto FluentUI's render pass and prove itFollow-ups
MudBlazorFileUploadFieldComponent.razor,MudBlazorMultipleFileUploadComponent.razor) never bindIsDisabled, so neither.Disabled()nor.DisabledWhen(...)disables them (MudFileUpload, the drop zone, Browse and Clear stay active). Their Fluent counterparts do bind it. This predates this PR (found in review).FormCraft/Forms/Rendering/{String,Int,Decimal,Double,Bool,DateTime,FileUpload}FieldRenderer.cs) still readContext.Field.IsDisableddirectly, so they ignoreDisabledWhen. They are only used when no adapter is registered.FieldContext(custom templates) has no disabled state, so template authors have to evaluateDisabledConditionthemselves. Either document that or expose an effective-disabled value.🤖 Generated with Claude Code