Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Reattach the click event to anchored buttons. Fixes #2754
  • Loading branch information
MarvinKlein1508 committed Nov 16, 2024
commit 6550b0b7514cc42f1f95a4f6ac3fc985b827ed4c
12 changes: 6 additions & 6 deletions src/Core/Components/InputFile/FluentInputFile.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -201,13 +201,13 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
{
Module ??= await JSRuntime.InvokeAsync<IJSObjectReference>("import", JAVASCRIPT_FILE.FormatCollocatedUrl(LibraryConfiguration));

if (!string.IsNullOrEmpty(AnchorId))
{
await Module.InvokeVoidAsync("attachClickHandler", AnchorId, Id);
}

_containerInstance = await Module.InvokeAsync<IJSObjectReference>("initializeFileDropZone", _containerElement, _inputFile!.Element);
}

if (!string.IsNullOrEmpty(AnchorId) && Module is not null)
{
await Module.InvokeVoidAsync("attachClickHandler", AnchorId, Id);
}
}

/// <summary />
Expand Down
6 changes: 5 additions & 1 deletion src/Core/Components/InputFile/FluentInputFile.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down