Hi I have created a git repo to make it easier to reproduce the error I am getting.
This is what I am trying:
Call a custom dialog using await. From the dialog I need to show a confirm dialog if the user wants to deactivate the contact person.
When the user choose to deactivate the contact the confirm dialog closes and then I close the dialog, this does not return to the calling code.
On the Index page
private async Task EditContactButtonClick()
{
var contactToEdit = new Contact();
try
{
var objAsync = await DialogService.OpenAsync<ContactCreate>(
"Edit Contact",
new Dictionary<string, object> { { "Contact", contactToEdit } });
if (!(objAsync is Contact contactToUpdate))
{
Notifications.Notify(NotificationSeverity.Info, "Dialog was cancelled ", duration: 10_000);
return; // maybe canceled edit then objAsync has the value true
}
Notifications.Notify(NotificationSeverity.Success, $"Contact is {contactToUpdate.Active}", duration: 10_000);
}
catch (Exception e)
{
Notifications.Notify(NotificationSeverity.Error, "Unable to update the contact, " + e.Message);
}
}
In the code for the custom dialog
public partial class ContactCreate
{
[Inject]
private DialogService DialogService { get; set; }
[Parameter]
public Contact Contact { get; set; } = new Contact();
private async Task InactivateContactButtonClicked()
{
if (await DialogService.Confirm("Setting a contact inactive will also remove all reports for that contact. ", "Inactivate Contact?") == false)
{
return;
}
Contact.Active = false;
DialogService.Close(Contact);
}
private void HandleValidSubmit()
{
DialogService.Close(Contact);
}
}
The code in the InactivateContactButtonClicked waits for the confirm dialog and then closes itself DialogService.Close(Contact); But the calling procedure EditContactButtonClick are not called.