diff --git a/examples/Demo/Shared/Pages/InputFile/Examples/InputFileLoading.razor b/examples/Demo/Shared/Pages/InputFile/Examples/InputFileLoading.razor
new file mode 100644
index 0000000000..3f3543d7f7
--- /dev/null
+++ b/examples/Demo/Shared/Pages/InputFile/Examples/InputFileLoading.razor
@@ -0,0 +1,66 @@
+
+
+
+
+ @progressTitle
+
+
+
+ Upload files
+
+
+@if (Files.Any())
+{
+
File(s) uploaded:
+
+ @foreach (var file in Files)
+ {
+ -
+ @file.Name 🔹
+ @($"{Decimal.Divide(file.Size, 1024):N} KB") 🔹
+ @file.ContentType 🔹
+ @file.LocalFile?.FullName
+ @file.ErrorMessage
+
+ }
+
+}
+
+
+@code
+{
+ bool _formUploading;
+ FluentInputFile? myFileUploader = default!;
+ int? progressPercent;
+ string? progressTitle;
+
+ FluentInputFileEventArgs[] Files = Array.Empty();
+
+ void OnCompleted(IEnumerable files)
+ {
+ Files = files.ToArray();
+ progressPercent = myFileUploader!.ProgressPercent;
+ progressTitle = myFileUploader!.ProgressTitle;
+
+ // For the demo, delete these files.
+ foreach (var file in Files)
+ {
+ file.LocalFile?.Delete();
+ }
+ _formUploading = false;
+ StateHasChanged();
+ }
+}
diff --git a/examples/Demo/Shared/Pages/InputFile/InputFilePage.razor b/examples/Demo/Shared/Pages/InputFile/InputFilePage.razor
index bbffd29133..f2f4a86b4d 100644
--- a/examples/Demo/Shared/Pages/InputFile/InputFilePage.razor
+++ b/examples/Demo/Shared/Pages/InputFile/InputFilePage.razor
@@ -33,6 +33,12 @@
+
+
+
+
+
+
diff --git a/src/Core/Components/InputFile/FluentInputFile.razor.cs b/src/Core/Components/InputFile/FluentInputFile.razor.cs
index 85a5e7c2fb..b1b34cd362 100644
--- a/src/Core/Components/InputFile/FluentInputFile.razor.cs
+++ b/src/Core/Components/InputFile/FluentInputFile.razor.cs
@@ -12,7 +12,7 @@ public partial class FluentInputFile : FluentComponentBase, IAsyncDisposable
private ElementReference? _containerElement;
private InputFile? _inputFile;
private IJSObjectReference? _containerInstance;
-
+
public static string ResourceLoadingBefore = "Loading...";
public static string ResourceLoadingCompleted = "Completed";
public static string ResourceLoadingCanceled = "Canceled";
@@ -201,13 +201,13 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
Module ??= await JSRuntime.InvokeAsync("import", JAVASCRIPT_FILE.FormatCollocatedUrl(LibraryConfiguration));
- if (!string.IsNullOrEmpty(AnchorId))
- {
- await Module.InvokeVoidAsync("attachClickHandler", AnchorId, Id);
- }
-
_containerInstance = await Module.InvokeAsync("initializeFileDropZone", _containerElement, _inputFile!.Element);
}
+
+ if (!string.IsNullOrEmpty(AnchorId) && Module is not null)
+ {
+ await Module.InvokeVoidAsync("attachClickHandler", AnchorId, Id);
+ }
}
///
diff --git a/src/Core/Components/InputFile/FluentInputFile.razor.js b/src/Core/Components/InputFile/FluentInputFile.razor.js
index 969a397ab6..712c510128 100644
--- a/src/Core/Components/InputFile/FluentInputFile.razor.js
+++ b/src/Core/Components/InputFile/FluentInputFile.razor.js
@@ -8,10 +8,14 @@ export function raiseFluentInputFile(fileInputId) {
export function attachClickHandler(buttonId, fileInputId) {
var button = document.getElementById(buttonId);
var fileInput = document.getElementById(fileInputId);
- if (button && fileInput) {
+
+ if (button && fileInput && !button.fluentuiBlazorFileInputHandlerAttached) {
+
button.addEventListener("click", function (e) {
fileInput.click();
});
+
+ button.fluentuiBlazorFileInputHandlerAttached = true;
}
}