I am injecting the DialogService to open side async a component I created. When I close the dialog using the buttons I created within it, I can set the return value while closing the dialog.
The problem is when I close the dialog by using the default X button from the 'ShowClose = true' or when I click outside the dialog, the awaited DialogService.OpenSideAsync returns before the Subscription to OnClose and OnSideClose triggers.
Then the returned value from the awaited OpenSideAsync is null, which I would like to set before returning.
Opening the dialog :
var dynamicResult = await dialogService.OpenSideAsync<TComponentDialog>(title, parameters, options: dialogOptions);
// Problem here : dynamicResult is null when dialog closed with default X and/or clicking outside the dialog
if (dynamicResult == null)
{
...
}
Subscription (tried both one by one and together, didn't work):
protected override async Task OnInitializedAsync()
{
DialogService.OnSideClose += Close;
DialogService.OnClose += Close;
...
}
Closing the dialog with the buttons within the component :
DialogService.CloseSide(new ContentDialogResult<FiltersGridDemandesDto> { DialogResult = DialogResult.Ok, ReturnResult = some_stuff});
Is there a DialogOption I'm missing or a way to trigger my subscriptions before the OpenSideAsync is returned ?
Thanks
Edit : The DialogService I'm using is Radzen.DialogService.