Skip to content
Merged
Changes from all commits
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
19 changes: 12 additions & 7 deletions src/Core/Components/Dialog/FluentDialogProvider.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@

private async Task<IDialogReference> ShowDialogAsync(IDialogReference dialogReference, Type? dialogComponent, DialogParameters parameters, object content)
{
return await Task.Run(async () =>
await InvokeAsync(async () =>
{
var previouslyFocusedElement = await GetPreviouslyFocusedElementAsync();

DialogInstance dialog = new(dialogComponent, parameters, content, previouslyFocusedElement);
dialogReference.Instance = dialog;

_internalDialogContext.References.Add(dialogReference);
await InvokeAsync(StateHasChanged);

return dialogReference;
StateHasChanged();
});

return dialogReference;
}

private void UpdateDialog(string? dialogId, DialogParameters parameters)
Expand All @@ -116,7 +116,9 @@

private async Task<IDialogReference?> UpdateDialogAsync(string? dialogId, DialogParameters parameters)
{
return await Task.Run(() =>
IDialogReference? result = null;

await InvokeAsync(() =>
{
IDialogReference? reference = _internalDialogContext.References.SingleOrDefault(x => x.Id == dialogId)!;
DialogInstance? dialogInstance = reference?.Instance;
Expand All @@ -130,10 +132,13 @@
dialogInstance.Content = content;
}

InvokeAsync(StateHasChanged);
StateHasChanged();
}
return reference;

result = reference;
});

return result;
}

// Check if the content object is a IDialogParameters<TContent> and get the Content property.
Expand Down Expand Up @@ -233,7 +238,7 @@

public async ValueTask DisposeAsync()
{
if (NavigationManager != null)

Check warning on line 241 in src/Core/Components/Dialog/FluentDialogProvider.razor.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Null check can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0031)

Check warning on line 241 in src/Core/Components/Dialog/FluentDialogProvider.razor.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Null check can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0031)

Check warning on line 241 in src/Core/Components/Dialog/FluentDialogProvider.razor.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Null check can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0031)

Check warning on line 241 in src/Core/Components/Dialog/FluentDialogProvider.razor.cs

View workflow job for this annotation

GitHub Actions / Build and Test Core Lib

Null check can be simplified (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/ide0031)
{
NavigationManager.LocationChanged -= LocationChanged;
}
Expand Down
Loading