Skip to content

Commit

Permalink
[FluentInputFile] Add OnFileCountExceeded callback (#3205)
Browse files Browse the repository at this point in the history
Co-authored-by: rpodevns <[email protected]>
  • Loading branch information
rpodevns and rpodevns authored Jan 18, 2025
1 parent 81aa14d commit c180795
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5145,6 +5145,12 @@
Raise when a file raised an error. Not yet used.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentInputFile.OnFileCountExceeded">
<summary>
Raised when the <see cref="P:Microsoft.FluentUI.AspNetCore.Components.FluentInputFile.MaximumFileCount"/> is exceeded.
The return parameter specifies the total number of files that were attempted for upload.
</summary>
</member>
<member name="P:Microsoft.FluentUI.AspNetCore.Components.FluentInputFile.OnCompleted">
<summary>
Raise when all files are completely uploaded.
Expand Down
13 changes: 12 additions & 1 deletion src/Core/Components/InputFile/FluentInputFile.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ public FluentInputFile()
[Parameter]
public EventCallback<FluentInputFileEventArgs> OnFileError { get; set; }

/// <summary>
/// Raised when the <see cref="MaximumFileCount"/> is exceeded.
/// The return parameter specifies the total number of files that were attempted for upload.
/// </summary>
[Parameter]
public EventCallback<int> OnFileCountExceeded { get; set; }

/// <summary>
/// Raise when all files are completely uploaded.
/// </summary>
Expand Down Expand Up @@ -215,7 +222,11 @@ protected async Task OnUploadFilesHandlerAsync(InputFileChangeEventArgs e)
{
if (e.FileCount > MaximumFileCount)
{
throw new ApplicationException($"The maximum number of files accepted is {MaximumFileCount}, but {e.FileCount} were supplied.");
if (OnFileCountExceeded.HasDelegate)
{
await OnFileCountExceeded.InvokeAsync(e.FileCount);
}
return;
}

// Use the native Blazor event
Expand Down

0 comments on commit c180795

Please sign in to comment.