Skip to content

MudFileUpload: Remove IActivator, Add defaults#10487

Merged
danielchalmers merged 64 commits intoMudBlazor:devfrom
versile2:enhance/fileupload
Feb 9, 2026
Merged

MudFileUpload: Remove IActivator, Add defaults#10487
danielchalmers merged 64 commits intoMudBlazor:devfrom
versile2:enhance/fileupload

Conversation

@versile2
Copy link
Contributor

@versile2 versile2 commented Dec 19, 2024

Description

Resolves #9870 - one of the examples in Docs is that problem.
Resolves #9596 by allowing full customization
Remove IActivator from MudFileUpload
Add Default behavior to MudFileUpload
Add built in Drag and Drop behavior to MudFileUpload
Created public property DragandDrop to enable built in drag and drop functionality
Created public property Dragging to monitor drag and drop events or interact directly
Created public method GetFilenames
Created public method RemoveFile
Extensive Docs modifications
Ensure minimal change for existing installations - Migration guide would include:

Caution

MudFileUpload's ActivationContent won't automatically open the picker any longer. Please add an onclick handler as needed. e.g. OnClick="@context.OpenFilePickerAsync".

MudFileUpload: ActivationContent was renamed to CustomContent which contains a MudFileUpload context.
MudFileUpload: Activate(...) was removed, use OpenFilePickerAsync() instead
MudFileUpload: If SelectedTemplate was not used it will render a default file list. <SelectedTemplate /> will remove it.

How Has This Been Tested?

Visually, Unit Tests (Added missing and new tests as well)

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Default MudFileUpload

<MudFileUpload T="IReadOnlyList<IBrowserFile>"
               AppendMultipleFiles />

image

Default MudFileUpload with DragandDrop

<MudFileUpload T="IReadOnlyList<IBrowserFile>"
               Style="height: 300px;width: 300px;"
               AppendMultipleFiles
               DragAndDrop />

image

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

@github-actions github-actions bot added breaking change This change will require consumer code updates bug Unexpected behavior or functionality not working as intended docs Updates/improvements to project documentation that do not affect core library logic enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library labels Dec 19, 2024
@versile2 versile2 changed the title Enhance/fileupload FileUpload Remove IActivator And Add Defaults Dec 19, 2024
@versile2
Copy link
Contributor Author

@ScarletKuro @henon If this meets approval I'll redo the Docs page, list all the fixes, and change from draft PR. This changes MudFileUpload to follow the style of other components using context inside the ActivatorContent instead of IActivator. I also took the time to create default implementations.

@ScarletKuro
Copy link
Member

In general looks good to me, but probs would require @igotinfected to look at this

@versile2
Copy link
Contributor Author

Updated https://try.arctechonline.tech with this version if you want to test anything.

@henon
Copy link
Contributor

henon commented Dec 20, 2024

@Mr-Technician could you take a look too please?

@henon henon requested a review from Mr-Technician December 20, 2024 10:50
@henon henon removed bug Unexpected behavior or functionality not working as intended docs Updates/improvements to project documentation that do not affect core library logic labels Dec 20, 2024
@codecov
Copy link

codecov bot commented Dec 20, 2024

Codecov Report

Attention: Patch coverage is 90.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 91.59%. Comparing base (be169a7) to head (293363b).

Files with missing lines Patch % Lines
...lazor/Components/FileUpload/MudFileUpload.razor.cs 90.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##              dev   #10487   +/-   ##
=======================================
  Coverage   91.59%   91.59%           
=======================================
  Files         426      426           
  Lines       13295    13312   +17     
  Branches     2558     2561    +3     
=======================================
+ Hits        12177    12193   +16     
  Misses        546      546           
- Partials      572      573    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@igotinfected igotinfected left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general LGTM for the built-in drag and drop functionality, however I think that the ActivatorContent is now confusing to use.

The original goal of ActivatorContent was to make it so that anything within ActivatorContent triggers the file picker, without any extra user setup. Previously you had to mess around with a label button + for attribute:

image

With this implementation we're asking the user to add an @onclick to define the activator.

My preference would be to keep anything within the ActivatorContent as an activation trigger for the file picker, but we could also just rename the ActivatorContent for clarity.

@henon henon changed the title FileUpload Remove IActivator And Add Defaults MudFileUpload: Remove IActivator and Add Defaults Dec 20, 2024
@versile2
Copy link
Contributor Author

In general LGTM for the built-in drag and drop functionality, however I think that the ActivatorContent is now confusing to use.

The original goal of ActivatorContent was to make it so that anything within ActivatorContent triggers the file picker, without any extra user setup. Previously you had to mess around with a label button + for attribute:

image

With this implementation we're asking the user to add an @onclick to define the activator.

My preference would be to keep anything within the ActivatorContent as an activation trigger for the file picker, but we could also just rename the ActivatorContent for clarity.

If I am being honest, ActivatorContent and SelectedTemplate are the wrong terms, it should be CustomContent (or something to indicate they are overriding) and FilesTemplate (or something to indicate they can customize the style of files). That being said IActivator I think caused more issues than it solved and this removes it by using context (like MudStepper and soon MudMenu). It's an easy change for people to make and doesn't require anything funny to make work, the user has full control.

I wasn't around for the label button + for, glad I missed those days! Either way I'm 100% flexible my goal was to make the component easier to use in the future while maintaining past functionality as much as possible.

@igotinfected
Copy link
Member

That being said IActivator I think caused more issues than it solved

You're right, your implementation makes sense, it's more flexible, and less magic behind the scenes with the IActivatable. I'm happy as long as we fix up the naming and documentation surrounding usage!

As for ActivatorContent and SelectedTemplate... couldn't they just be merged now? Don't we have access to the files within the ActivatorContent context?

For naming I have no clue, CustomContent, FileUploadContent, FileUploadTemplate, ... I'll let people better at naming than me decide :')

@versile2
Copy link
Contributor Author

That being said IActivator I think caused more issues than it solved

You're right, your implementation makes sense, it's more flexible, and less magic behind the scenes with the IActivatable. I'm happy as long as we fix up the naming and documentation surrounding usage!

As for ActivatorContent and SelectedTemplate... couldn't they just be merged now? Don't we have access to the files within the ActivatorContent context?

For naming I have no clue, CustomContent, FileUploadContent, FileUploadTemplate, ... I'll let people better at naming than me decide :')

So do we want to rename them now? I like the idea of them being separate so the user can use the default setup and still customize or not show the files as they choose. (For example if they upload immediately they might just want to show a progress bar)

This was referenced Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change This change will require consumer code updates enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library

Projects

None yet