Registry Mirror
Skip to content

Conversation

@phmatray

@phmatray phmatray commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • MudBlazorFileUploadFieldComponent and MudBlazorMultipleFileUploadComponent never bound
    Disabled, so .Disabled()/.DisabledWhen(...) had no effect on either upload field.
  • Both components now bind Disabled="@IsDisabled" on MudFileUpload, the Browse button, and
    the Clear/Clear All button — matching FluentUI's existing parity.
  • OpenFilePickerAsync() in both components is guarded directly, since the drop zone's
    @onclick calls it without going through any Disabled-bound control.
  • RemoveFile(...) in the multiple-file component is guarded directly, since a chip's close
    callback is FormCraft's own CustomContent and no Disabled binding reaches it.
  • SetDragClass() in both components is guarded too (found in review): @ondragenter is the
    same kind of unguarded FormCraft handler, so a disabled field was still showing drag-hover
    feedback even though the drop itself is already blocked at the MudBlazor layer.

Follow-up from #479, closes #482.

Fixed along the way

  • Guarded SetDragClass() against IsDisabled in both components — a review finding, same
    root cause as the OpenFilePickerAsync() guard (a FormCraft-owned handler not gated by
    MudBlazor's Disabled), fixed in the same files this PR already touches.

Test plan

  • SingleFileUploadDisabledWhenTests (new) — .DisabledWhen(...) disables MudFileUpload,
    Browse and Clear at first render, follows the watched field on every render, and the drop
    zone's click is a no-op while disabled (with a positive control).
  • MultipleFileUploadDisabledWhenTests (new) — same coverage plus Clear All, AC4 (closing a
    file chip while disabled does not mutate the model), and the drop-zone click no-op.
  • dotnet test FormCraft.ForMudBlazor.UnitTests/FormCraft.ForMudBlazor.UnitTests.csproj -c Release — 735/735 passed.
  • dotnet test -c Release (full solution) — 2134/2134 passed.
  • dotnet format FormCraft.sln --verify-no-changes — clean.
  • Independent code review (read-only agent) — no blocking correctness findings; confirmed
    no drag-and-drop bypass at the data level, no regression risk to existing file-upload suites,
    and that the focus-restore convention does not apply here (the disabled field is always the
    dependent field, never the one whose own click disabled it).

🤖 Generated with Claude Code

phmatray and others added 5 commits September 24, 2026 11:21
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>
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>
…oads

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>
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>
@phmatray
phmatray marked this pull request as ready for review September 24, 2026 09:39
@phmatray
phmatray merged commit 0343e59 into dev Sep 24, 2026
4 checks passed
@phmatray
phmatray deleted the fix/482-disabled-mudblazor-file-upload branch September 24, 2026 09:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(mudblazor): bind DisabledWhen to MudBlazor file upload components

1 participant